@openglobus/og 0.12.1 → 0.13.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.
Files changed (230) hide show
  1. package/README.md +0 -2
  2. package/dist/@openglobus/og.css +1 -0
  3. package/dist/@openglobus/og.esm.js +21 -0
  4. package/dist/@openglobus/og.esm.js.map +1 -0
  5. package/dist/@openglobus/og.umd.js +21 -0
  6. package/dist/@openglobus/og.umd.js.map +1 -0
  7. package/package.json +8 -8
  8. package/src/og/Extent.js +3 -3
  9. package/src/og/Globe.js +277 -275
  10. package/src/og/ImageCanvas.js +3 -3
  11. package/src/og/LonLat.js +9 -9
  12. package/src/og/QueueArray.js +2 -2
  13. package/src/og/Rectangle.js +5 -5
  14. package/src/og/bv/Box.js +1 -1
  15. package/src/og/bv/Sphere.js +2 -2
  16. package/src/og/camera/Camera.js +1 -1
  17. package/src/og/camera/PlanetCamera.js +649 -646
  18. package/src/og/control/LayerSwitcher.js +1 -1
  19. package/src/og/control/MouseNavigation.js +22 -13
  20. package/src/og/control/MouseWheelZoomControl.js +2 -2
  21. package/src/og/control/ScaleControl.js +1 -1
  22. package/src/og/control/TouchNavigation.js +319 -319
  23. package/src/og/control/ZoomControl.js +132 -132
  24. package/src/og/control/visibleExtent/Segment.js +12 -12
  25. package/src/og/ellipsoid/Ellipsoid.js +577 -567
  26. package/src/og/entity/BillboardHandler.js +878 -1051
  27. package/src/og/entity/Entity.js +1 -1
  28. package/src/og/entity/EntityCollection.js +847 -857
  29. package/src/og/entity/GeoObjectHandler.js +37 -18
  30. package/src/og/entity/LabelHandler.js +888 -1040
  31. package/src/og/entity/LabelWorker.js +0 -6
  32. package/src/og/entity/PointCloud.js +495 -495
  33. package/src/og/entity/Polyline.js +2218 -2222
  34. package/src/og/entity/RayHandler.js +1 -1
  35. package/src/og/layer/CanvasTiles.js +6 -3
  36. package/src/og/layer/GeoImage.js +1 -1
  37. package/src/og/layer/KML.js +24 -17
  38. package/src/og/layer/Layer.js +806 -751
  39. package/src/og/layer/Vector.js +997 -1010
  40. package/src/og/layer/XYZ.js +359 -357
  41. package/src/og/math/Line2.js +4 -4
  42. package/src/og/math/Quat.js +2 -2
  43. package/src/og/math/Ray.js +2 -2
  44. package/src/og/math/Vec2.js +524 -524
  45. package/src/og/math/Vec3.js +900 -900
  46. package/src/og/math/Vec4.js +261 -261
  47. package/src/og/math.js +397 -398
  48. package/src/og/quadTree/EntityCollectionNode.js +389 -387
  49. package/src/og/renderer/Renderer.js +14 -20
  50. package/src/og/renderer/RendererEvents.js +1034 -1045
  51. package/src/og/scene/Planet.js +26 -23
  52. package/src/og/scene/RenderNode.js +347 -354
  53. package/src/og/segment/Segment.js +3 -1
  54. package/src/og/segment/SegmentLonLat.js +1 -4
  55. package/src/og/shaders/billboard.js +220 -204
  56. package/src/og/shaders/drawnode.js +603 -603
  57. package/src/og/shaders/geoObject.js +15 -6
  58. package/src/og/shaders/label.js +596 -456
  59. package/src/og/shaders/polyline.js +365 -361
  60. package/src/og/terrain/MapboxTerrain.js +1 -1
  61. package/src/og/utils/FontAtlas.js +209 -200
  62. package/src/og/utils/GeoImageCreator.js +4 -5
  63. package/src/og/utils/TextureAtlas.js +4 -4
  64. package/src/og/utils/VectorTileCreator.js +414 -414
  65. package/src/og/utils/shared.js +1 -1
  66. package/src/og/webgl/Handler.js +28 -60
  67. package/src/og/webgl/Multisample.js +260 -260
  68. package/src/og/webgl/Program.js +411 -396
  69. package/types/Clock.d.ts +94 -0
  70. package/types/Deferred.d.ts +6 -0
  71. package/types/Events.d.ts +77 -0
  72. package/types/Extent.d.ts +166 -0
  73. package/types/Globe.d.ts +85 -0
  74. package/types/ImageCanvas.d.ts +123 -0
  75. package/types/Lock.d.ts +12 -0
  76. package/types/LonLat.d.ts +108 -0
  77. package/types/Popup.d.ts +42 -0
  78. package/types/QueueArray.d.ts +19 -0
  79. package/types/Rectangle.d.ts +80 -0
  80. package/types/Stack.d.ts +19 -0
  81. package/types/ajax.d.ts +24 -0
  82. package/types/arial.d.ts +48 -0
  83. package/types/astro/astro.d.ts +38 -0
  84. package/types/astro/earth.d.ts +7 -0
  85. package/types/astro/jd.d.ts +254 -0
  86. package/types/bv/Box.d.ts +30 -0
  87. package/types/bv/Sphere.d.ts +38 -0
  88. package/types/bv/index.d.ts +3 -0
  89. package/types/camera/Camera.d.ts +312 -0
  90. package/types/camera/Frustum.d.ts +133 -0
  91. package/types/camera/PlanetCamera.d.ts +219 -0
  92. package/types/camera/index.d.ts +3 -0
  93. package/types/cons.d.ts +40 -0
  94. package/types/control/CompassButton.d.ts +17 -0
  95. package/types/control/Control.d.ts +104 -0
  96. package/types/control/DebugInfo.d.ts +15 -0
  97. package/types/control/EarthCoordinates.d.ts +47 -0
  98. package/types/control/EarthNavigation.d.ts +43 -0
  99. package/types/control/GeoImageDragControl.d.ts +6 -0
  100. package/types/control/KeyboardNavigation.d.ts +21 -0
  101. package/types/control/LayerSwitcher.d.ts +21 -0
  102. package/types/control/Lighting.d.ts +16 -0
  103. package/types/control/MouseNavigation.d.ts +48 -0
  104. package/types/control/MouseWheelZoomControl.d.ts +45 -0
  105. package/types/control/ScaleControl.d.ts +22 -0
  106. package/types/control/ShowFps.d.ts +11 -0
  107. package/types/control/SimpleNavigation.d.ts +25 -0
  108. package/types/control/Sun.d.ts +50 -0
  109. package/types/control/ToggleWireframe.d.ts +12 -0
  110. package/types/control/TouchNavigation.d.ts +48 -0
  111. package/types/control/ZoomControl.d.ts +27 -0
  112. package/types/control/index.d.ts +18 -0
  113. package/types/ellipsoid/Ellipsoid.d.ts +153 -0
  114. package/types/ellipsoid/index.d.ts +3 -0
  115. package/types/ellipsoid/wgs84.d.ts +6 -0
  116. package/types/entity/BaseBillboard.d.ts +215 -0
  117. package/types/entity/Billboard.d.ts +94 -0
  118. package/types/entity/BillboardHandler.d.ts +75 -0
  119. package/types/entity/Entity.d.ts +348 -0
  120. package/types/entity/EntityCollection.d.ts +309 -0
  121. package/types/entity/GeoObject.d.ts +111 -0
  122. package/types/entity/GeoObjectHandler.d.ts +81 -0
  123. package/types/entity/Geometry.d.ts +74 -0
  124. package/types/entity/GeometryHandler.d.ts +76 -0
  125. package/types/entity/Label.d.ts +189 -0
  126. package/types/entity/LabelHandler.d.ts +29 -0
  127. package/types/entity/LabelWorker.d.ts +11 -0
  128. package/types/entity/PointCloud.d.ts +174 -0
  129. package/types/entity/PointCloudHandler.d.ts +38 -0
  130. package/types/entity/Polyline.d.ts +306 -0
  131. package/types/entity/PolylineHandler.d.ts +18 -0
  132. package/types/entity/Ray.d.ts +124 -0
  133. package/types/entity/RayHandler.d.ts +67 -0
  134. package/types/entity/ShapeHandler.d.ts +22 -0
  135. package/types/entity/Strip.d.ts +119 -0
  136. package/types/entity/StripHandler.d.ts +38 -0
  137. package/types/entity/index.d.ts +8 -0
  138. package/types/index.core.d.ts +65 -0
  139. package/types/index.d.ts +45 -0
  140. package/types/index.webgl.d.ts +7 -0
  141. package/types/input/KeyboardHandler.d.ts +10 -0
  142. package/types/input/MouseHandler.d.ts +5 -0
  143. package/types/input/TouchHandler.d.ts +5 -0
  144. package/types/input/input.d.ts +34 -0
  145. package/types/layer/BaseGeoImage.d.ts +94 -0
  146. package/types/layer/CanvasTiles.d.ts +67 -0
  147. package/types/layer/GeoImage.d.ts +52 -0
  148. package/types/layer/GeoTexture2d.d.ts +8 -0
  149. package/types/layer/GeoVideo.d.ts +55 -0
  150. package/types/layer/KML.d.ts +68 -0
  151. package/types/layer/Layer.d.ts +315 -0
  152. package/types/layer/Material.d.ts +45 -0
  153. package/types/layer/Vector.d.ts +201 -0
  154. package/types/layer/WMS.d.ts +61 -0
  155. package/types/layer/XYZ.d.ts +119 -0
  156. package/types/layer/index.d.ts +10 -0
  157. package/types/light/LightSource.d.ts +178 -0
  158. package/types/math/Line2.d.ts +11 -0
  159. package/types/math/Line3.d.ts +10 -0
  160. package/types/math/Mat3.d.ts +65 -0
  161. package/types/math/Mat4.d.ts +176 -0
  162. package/types/math/Plane.d.ts +18 -0
  163. package/types/math/Quat.d.ts +379 -0
  164. package/types/math/Ray.d.ts +82 -0
  165. package/types/math/Vec2.d.ts +309 -0
  166. package/types/math/Vec3.d.ts +467 -0
  167. package/types/math/Vec4.d.ts +162 -0
  168. package/types/math/coder.d.ts +43 -0
  169. package/types/math/index.d.ts +11 -0
  170. package/types/math.d.ts +261 -0
  171. package/types/mercator.d.ts +92 -0
  172. package/types/proj/EPSG3857.d.ts +6 -0
  173. package/types/proj/EPSG4326.d.ts +6 -0
  174. package/types/proj/Proj.d.ts +42 -0
  175. package/types/quadTree/EntityCollectionNode.d.ts +34 -0
  176. package/types/quadTree/Node.d.ts +60 -0
  177. package/types/quadTree/quadTree.d.ts +40 -0
  178. package/types/renderer/Renderer.d.ts +290 -0
  179. package/types/renderer/RendererEvents.d.ts +237 -0
  180. package/types/res/images.d.ts +3 -0
  181. package/types/scene/Axes.d.ts +11 -0
  182. package/types/scene/BaseNode.d.ts +60 -0
  183. package/types/scene/Planet.d.ts +576 -0
  184. package/types/scene/RenderNode.d.ts +142 -0
  185. package/types/scene/SkyBox.d.ts +10 -0
  186. package/types/scene/index.d.ts +4 -0
  187. package/types/segment/Segment.d.ts +275 -0
  188. package/types/segment/SegmentLonLat.d.ts +17 -0
  189. package/types/segment/Slice.d.ts +10 -0
  190. package/types/segment/segmentHelper.d.ts +13 -0
  191. package/types/shaders/billboard.d.ts +3 -0
  192. package/types/shaders/depth.d.ts +2 -0
  193. package/types/shaders/drawnode.d.ts +7 -0
  194. package/types/shaders/geoObject.d.ts +3 -0
  195. package/types/shaders/label.d.ts +4 -0
  196. package/types/shaders/pointCloud.d.ts +2 -0
  197. package/types/shaders/polyline.d.ts +3 -0
  198. package/types/shaders/ray.d.ts +2 -0
  199. package/types/shaders/screenFrame.d.ts +2 -0
  200. package/types/shaders/shape.d.ts +4 -0
  201. package/types/shaders/skybox.d.ts +2 -0
  202. package/types/shaders/toneMapping.d.ts +2 -0
  203. package/types/shapes/BaseShape.d.ts +250 -0
  204. package/types/shapes/Sphere.d.ts +41 -0
  205. package/types/terrain/BilTerrain.d.ts +7 -0
  206. package/types/terrain/EmptyTerrain.d.ts +73 -0
  207. package/types/terrain/Geoid.d.ts +26 -0
  208. package/types/terrain/GlobusTerrain.d.ts +116 -0
  209. package/types/terrain/MapboxTerrain.d.ts +7 -0
  210. package/types/terrain/index.d.ts +5 -0
  211. package/types/utils/FontAtlas.d.ts +16 -0
  212. package/types/utils/GeoImageCreator.d.ts +30 -0
  213. package/types/utils/ImagesCacheManager.d.ts +10 -0
  214. package/types/utils/Loader.d.ts +25 -0
  215. package/types/utils/NormalMapCreator.d.ts +39 -0
  216. package/types/utils/PlainSegmentWorker.d.ts +10 -0
  217. package/types/utils/TerrainWorker.d.ts +9 -0
  218. package/types/utils/TextureAtlas.d.ts +111 -0
  219. package/types/utils/VectorTileCreator.d.ts +16 -0
  220. package/types/utils/colorTable.d.ts +143 -0
  221. package/types/utils/earcut.d.ts +6 -0
  222. package/types/utils/shared.d.ts +231 -0
  223. package/types/webgl/Framebuffer.d.ts +135 -0
  224. package/types/webgl/Handler.d.ts +392 -0
  225. package/types/webgl/Multisample.d.ts +89 -0
  226. package/types/webgl/Program.d.ts +163 -0
  227. package/types/webgl/ProgramController.d.ts +89 -0
  228. package/types/webgl/callbacks.d.ts +1 -0
  229. package/types/webgl/index.d.ts +6 -0
  230. package/types/webgl/types.d.ts +2 -0
@@ -44,7 +44,7 @@ class MapboxTerrain extends GlobusTerrain {
44
44
  }
45
45
 
46
46
  isBlur(segment) {
47
- if (segment.tileZoom >= 18) {
47
+ if (segment.tileZoom >= 13) {
48
48
  return true;
49
49
  }
50
50
  return false;
@@ -1,204 +1,213 @@
1
- /**
2
- * @module og/utils/FontAtlas
3
- */
4
-
5
- 'use strict';
6
-
7
- import { Rectangle } from '../Rectangle.js';
8
- import { TextureAtlas, TextureAtlasNode } from './TextureAtlas.js';
9
- import { Deferred } from '../Deferred.js';
10
- import { ARIAL_FONT_B64 } from '../res/images.js';
11
-
12
- class FontAtlas {
13
- constructor() {
14
- this.atlasesArr = [];
15
- this.atlasIndexes = {};
16
- this.atlasIndexesDeferred = [];
17
- this.tokenImageSize = 64;
18
- this.samplerArr = [0];
19
- this._handler = null;
20
- }
21
-
22
- assignHandler(handler) {
23
- this._handler = handler;
24
- }
25
-
26
- getFontIndex(face) {
27
- let fullName = this.getFullIndex(face);
28
- if (!this.atlasIndexesDeferred[fullName]) {
29
- this.atlasIndexesDeferred[fullName] = new Deferred();
30
- }
31
- return this.atlasIndexesDeferred[fullName].promise;
32
- }
33
-
34
- getFullIndex(face) {
35
- return face.trim().toLowerCase();
36
- }
37
-
38
- _applyFontDataToAtlas(atlas, data) {
39
- let chars = data.chars;
40
-
41
- atlas.height = data.common.scaleH;
42
- atlas.width = data.common.scaleW;
43
- atlas.gliphSize = data.info.size;
44
- atlas.distanceRange = data.distanceField.distanceRange;
45
-
46
- let w = atlas.width,
47
- h = atlas.height,
48
- s = atlas.gliphSize;
49
-
50
- let idToChar = {};
51
-
52
- for (let i = 0; i < chars.length; i++) {
53
- let ci = chars[i];
54
- let ti = ci.char;
55
-
56
- idToChar[ci.id] = ti;
57
-
58
- let r = new Rectangle(ci.x, ci.y, ci.x + ci.width, ci.y + ci.height);
59
-
60
- let tc = new Array(12);
61
-
62
- tc[0] = r.left / w;
63
- tc[1] = r.top / h;
64
-
65
- tc[2] = r.left / w;
66
- tc[3] = r.bottom / h;
67
-
68
- tc[4] = r.right / w;
69
- tc[5] = r.bottom / h;
70
-
71
- tc[6] = r.right / w;
72
- tc[7] = r.bottom / h;
73
-
74
- tc[8] = r.right / w;
75
- tc[9] = r.top / h;
76
-
77
- tc[10] = r.left / w;
78
- tc[11] = r.top / h;
79
-
80
- atlas.nodes[ti] = new TextureAtlasNode(r, tc);
81
- atlas.nodes[ti].metrics = ci;
82
-
83
- atlas.nodes[ti].metrics.nWidth = atlas.nodes[ti].metrics.width / s;
84
- atlas.nodes[ti].metrics.nHeight = atlas.nodes[ti].metrics.height / s;
85
- atlas.nodes[ti].metrics.nAdvance = atlas.nodes[ti].metrics.xadvance / s;
86
- atlas.nodes[ti].metrics.nXOffset = atlas.nodes[ti].metrics.xoffset / s;
87
- atlas.nodes[ti].metrics.nYOffset = 1.0 - atlas.nodes[ti].metrics.yoffset / s;
88
-
89
- atlas.nodes[ti].emptySize = 1;
90
- }
91
-
92
- atlas.kernings = {};
93
-
94
- for (let i = 0; i < data.kernings.length; i++) {
95
- let ki = data.kernings[i];
96
-
97
- let first = ki.first,
98
- second = ki.second;
99
-
100
- let charFirst = idToChar[first],
101
- charSecond = idToChar[second];
102
-
103
- if (!atlas.kernings[charFirst]) {
104
- atlas.kernings[charFirst] = {};
105
- }
106
-
107
- atlas.kernings[charFirst][charSecond] = ki.amount / s;
108
- }
109
- }
110
-
111
- initFont(faceName, dataJson, imageBase64) {
112
- let index = this.atlasesArr.length;
113
- let fullName = this.getFullIndex(faceName);
114
-
115
- this.atlasIndexes[fullName] = index;
116
-
117
- let def = this.atlasIndexesDeferred[fullName];
118
- if (!def) {
119
- def = this.atlasIndexesDeferred[fullName] = new Deferred();
120
- }
121
-
122
- this.samplerArr[this.atlasesArr.length] = index;
123
-
124
- // TODO: FontTextureAtlas();
125
- let atlas = new TextureAtlas();
126
-
127
- atlas.height = 0;
128
- atlas.width = 0;
129
- atlas.gliphSize = 0;
130
- atlas.distanceRange = 0;
131
- atlas.kernings = {};
132
-
133
- atlas.assignHandler(this._handler);
134
-
135
- this.atlasesArr[index] = atlas;
136
-
137
- this._applyFontDataToAtlas(atlas, dataJson);
138
-
139
- let img = new Image();
140
- img.onload = () => {
141
- this._createTexture(atlas, img);
142
- def.resolve(index);
143
- };
144
- img.src = ARIAL_FONT_B64;
1
+ /**
2
+ * @module og/utils/FontAtlas
3
+ */
4
+
5
+ 'use strict';
6
+
7
+ import { Rectangle } from '../Rectangle.js';
8
+ import { TextureAtlas, TextureAtlasNode } from './TextureAtlas.js';
9
+ import { Deferred } from '../Deferred.js';
10
+ import { ARIAL_FONT_B64 } from '../res/images.js';
11
+
12
+ //TODO: get the value from shader module
13
+ const MAX_SIZE = 11;
14
+
15
+ class FontAtlas {
16
+ constructor() {
17
+ this.atlasesArr = [];
18
+ this.atlasIndexes = {};
19
+ this.atlasIndexesDeferred = [];
20
+ this.tokenImageSize = 64;
21
+ this.samplerArr = new Uint32Array(MAX_SIZE);
22
+ this.sdfParamsArr = new Float32Array(MAX_SIZE * 4);
23
+ this._handler = null;
24
+ }
25
+
26
+ assignHandler(handler) {
27
+ this._handler = handler;
28
+ }
29
+
30
+ getFontIndex(face) {
31
+ let fullName = this.getFullIndex(face);
32
+ if (!this.atlasIndexesDeferred[fullName]) {
33
+ this.atlasIndexesDeferred[fullName] = new Deferred();
34
+ }
35
+ return this.atlasIndexesDeferred[fullName].promise;
36
+ }
37
+
38
+ getFullIndex(face) {
39
+ return face.trim().toLowerCase();
40
+ }
41
+
42
+ _applyFontDataToAtlas(atlas, data, index = 0) {
43
+ let chars = data.chars;
44
+
45
+ atlas.height = data.common.scaleH;
46
+ atlas.width = data.common.scaleW;
47
+ atlas.gliphSize = data.info.size;
48
+ atlas.distanceRange = data.distanceField.distanceRange;
49
+
50
+ let w = atlas.width,
51
+ h = atlas.height,
52
+ s = atlas.gliphSize;
53
+
54
+ this.sdfParamsArr[index * 4] = w;
55
+ this.sdfParamsArr[index * 4 + 1] = h;
56
+ this.sdfParamsArr[index * 4 + 2] = s;
57
+ this.sdfParamsArr[index * 4 + 3] = atlas.distanceRange;
58
+
59
+ let idToChar = {};
60
+
61
+ for (let i = 0; i < chars.length; i++) {
62
+ let ci = chars[i];
63
+ let ti = ci.char;
64
+
65
+ idToChar[ci.id] = ti;
66
+
67
+ let r = new Rectangle(ci.x, ci.y, ci.x + ci.width, ci.y + ci.height);
68
+
69
+ let tc = new Array(12);
70
+
71
+ tc[0] = r.left / w;
72
+ tc[1] = r.top / h;
73
+
74
+ tc[2] = r.left / w;
75
+ tc[3] = r.bottom / h;
76
+
77
+ tc[4] = r.right / w;
78
+ tc[5] = r.bottom / h;
79
+
80
+ tc[6] = r.right / w;
81
+ tc[7] = r.bottom / h;
82
+
83
+ tc[8] = r.right / w;
84
+ tc[9] = r.top / h;
85
+
86
+ tc[10] = r.left / w;
87
+ tc[11] = r.top / h;
88
+
89
+ atlas.nodes[ti] = new TextureAtlasNode(r, tc);
90
+ atlas.nodes[ti].metrics = ci;
91
+
92
+ atlas.nodes[ti].metrics.nWidth = atlas.nodes[ti].metrics.width / s;
93
+ atlas.nodes[ti].metrics.nHeight = atlas.nodes[ti].metrics.height / s;
94
+ atlas.nodes[ti].metrics.nAdvance = atlas.nodes[ti].metrics.xadvance / s;
95
+ atlas.nodes[ti].metrics.nXOffset = atlas.nodes[ti].metrics.xoffset / s;
96
+ atlas.nodes[ti].metrics.nYOffset = 1.0 - atlas.nodes[ti].metrics.yoffset / s;
97
+
98
+ atlas.nodes[ti].emptySize = 1;
99
+ }
100
+
101
+ atlas.kernings = {};
102
+
103
+ for (let i = 0; i < data.kernings.length; i++) {
104
+ let ki = data.kernings[i];
105
+
106
+ let first = ki.first,
107
+ second = ki.second;
108
+
109
+ let charFirst = idToChar[first],
110
+ charSecond = idToChar[second];
111
+
112
+ if (!atlas.kernings[charFirst]) {
113
+ atlas.kernings[charFirst] = {};
114
+ }
115
+
116
+ atlas.kernings[charFirst][charSecond] = ki.amount / s;
117
+ }
118
+ }
119
+
120
+ initFont(faceName, dataJson, imageBase64) {
121
+ let index = this.atlasesArr.length;
122
+ let fullName = this.getFullIndex(faceName);
123
+
124
+ this.atlasIndexes[fullName] = index;
125
+
126
+ let def = this.atlasIndexesDeferred[fullName];
127
+ if (!def) {
128
+ def = this.atlasIndexesDeferred[fullName] = new Deferred();
129
+ }
130
+
131
+ this.samplerArr[this.atlasesArr.length] = index;
132
+
133
+ // TODO: FontTextureAtlas();
134
+ let atlas = new TextureAtlas();
135
+
136
+ atlas.height = 0;
137
+ atlas.width = 0;
138
+ atlas.gliphSize = 0;
139
+ atlas.distanceRange = 0;
140
+ atlas.kernings = {};
141
+
142
+ atlas.assignHandler(this._handler);
143
+
144
+ this.atlasesArr[index] = atlas;
145
+
146
+ this._applyFontDataToAtlas(atlas, dataJson, index);
147
+
148
+ let img = new Image();
149
+ img.onload = () => {
150
+ this._createTexture(atlas, img);
151
+ def.resolve(index);
152
+ };
153
+ img.src = ARIAL_FONT_B64;
145
154
  }
146
155
 
147
156
  _createTexture(atlas, img) {
148
- atlas.createTexture(img);
149
- }
150
-
151
- loadFont(faceName, srcDir, atlasUrl) {
152
-
153
- let index = this.atlasesArr.length;
154
- let fullName = this.getFullIndex(faceName);
155
-
156
- this.atlasIndexes[fullName] = index;
157
-
158
- let def = this.atlasIndexesDeferred[fullName];
159
- if (!def) {
160
- def = this.atlasIndexesDeferred[fullName] = new Deferred();
161
- }
162
-
163
- this.samplerArr[this.atlasesArr.length] = index;
164
-
165
- // TODO: FontTextureAtlas();
166
- let atlas = new TextureAtlas();
167
-
168
- atlas.height = 0;
169
- atlas.width = 0;
170
- atlas.gliphSize = 0;
171
- atlas.distanceRange = 0;
172
- atlas.kernings = {};
173
-
174
- atlas.assignHandler(this._handler);
175
- this.atlasesArr[index] = atlas;
176
-
177
- fetch(`${srcDir}/${atlasUrl}`)
178
- .then(response => {
179
- if (!response.ok) {
180
- throw Error(`Unable to load "${srcDir}/${atlasUrl}"`);
181
- }
182
- return response.json(response);
183
- })
184
- .then(data => {
185
-
186
- this._applyFontDataToAtlas(atlas, data);
187
-
188
- let img = new Image();
189
- img.onload = () => {
190
- this._createTexture(atlas, img);
191
- def.resolve(index);
192
- };
193
-
194
- img.src = `${srcDir}/${data.pages[0]}`;
195
- img.crossOrigin = "Anonymous";
196
- })
197
- .catch(err => {
198
- def.reject();
199
- return { 'status': "error", 'msg': err.toString() };
200
- });
201
- }
202
- }
203
-
157
+ atlas.createTexture(img);
158
+ }
159
+
160
+ loadFont(faceName, srcDir, atlasUrl) {
161
+
162
+ let index = this.atlasesArr.length;
163
+ let fullName = this.getFullIndex(faceName);
164
+
165
+ this.atlasIndexes[fullName] = index;
166
+
167
+ let def = this.atlasIndexesDeferred[fullName];
168
+ if (!def) {
169
+ def = this.atlasIndexesDeferred[fullName] = new Deferred();
170
+ }
171
+
172
+ this.samplerArr[this.atlasesArr.length] = index;
173
+
174
+ // TODO: FontTextureAtlas();
175
+ let atlas = new TextureAtlas();
176
+
177
+ atlas.height = 0;
178
+ atlas.width = 0;
179
+ atlas.gliphSize = 0;
180
+ atlas.distanceRange = 0;
181
+ atlas.kernings = {};
182
+
183
+ atlas.assignHandler(this._handler);
184
+ this.atlasesArr[index] = atlas;
185
+
186
+ fetch(`${srcDir}/${atlasUrl}`)
187
+ .then(response => {
188
+ if (!response.ok) {
189
+ throw Error(`Unable to load "${srcDir}/${atlasUrl}"`);
190
+ }
191
+ return response.json(response);
192
+ })
193
+ .then(data => {
194
+
195
+ this._applyFontDataToAtlas(atlas, data, index);
196
+
197
+ let img = new Image();
198
+ img.onload = () => {
199
+ this._createTexture(atlas, img);
200
+ def.resolve(index);
201
+ };
202
+
203
+ img.src = `${srcDir}/${data.pages[0]}`;
204
+ img.crossOrigin = "Anonymous";
205
+ })
206
+ .catch(err => {
207
+ def.reject();
208
+ return { 'status': "error", 'msg': err.toString() };
209
+ });
210
+ }
211
+ }
212
+
204
213
  export { FontAtlas };
@@ -136,8 +136,8 @@ export class GeoImageCreator {
136
136
  extentParams: { type: types.VEC4 }
137
137
  },
138
138
  attributes: {
139
- corners: { type: types.VEC2, enableArray: true },
140
- texCoords: { type: types.VEC2, enableArray: true }
139
+ corners: "vec2",
140
+ texCoords: "vec2"
141
141
  },
142
142
  vertexShader: `attribute vec2 corners;
143
143
  attribute vec2 texCoords;
@@ -153,12 +153,11 @@ export class GeoImageCreator {
153
153
  varying vec2 v_texCoords;
154
154
  void main () {
155
155
  if(v_texCoords.x <= 0.001 || v_texCoords.x >= 0.999 ||
156
- v_texCoords.y <= 0.001 || v_texCoords.y >= 0.999) {
157
- discard;
156
+ v_texCoords.y <= 0.001 || v_texCoords.y >= 0.999) {
157
+ discard;
158
158
  }
159
159
  gl_FragColor = texture2D(sourceTexture, v_texCoords);
160
160
  }`
161
161
  }));
162
162
  }
163
-
164
163
  }
@@ -12,7 +12,7 @@ import { ImagesCacheManager } from "./ImagesCacheManager.js";
12
12
  * @param {number} [height] - Texture atlas height, if it hasn't 1024 default..
13
13
  */
14
14
  class TextureAtlas {
15
- constructor(width, height) {
15
+ constructor(width = 1024, height = 1024) {
16
16
  /**
17
17
  * Atlas nodes where input images store. It can be access by image.__nodeIndex.
18
18
  * @public
@@ -31,7 +31,7 @@ class TextureAtlas {
31
31
  * @public
32
32
  * @type {canvas}
33
33
  */
34
- this.canvas = new ImageCanvas(width || 1024, height || 1024);
34
+ this.canvas = new ImageCanvas(width, height);
35
35
  this.clearCanvas();
36
36
 
37
37
  this._handler = null;
@@ -220,11 +220,11 @@ class TextureAtlas {
220
220
  * @param {Rectangle} rect - Node image rectangle.
221
221
  */
222
222
  class TextureAtlasNode {
223
- constructor(rect, texCoords) {
223
+ constructor(rect, texCoords = []) {
224
224
  this.childNodes = null;
225
225
  this.image = null;
226
226
  this.rect = rect;
227
- this.texCoords = texCoords || [];
227
+ this.texCoords = texCoords;
228
228
  this.atlas = null;
229
229
  }
230
230