babylon.rectangle2d.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. var __extends = (this && this.__extends) || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5. };
  6. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  7. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  8. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  9. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  10. return c > 3 && r && Object.defineProperty(target, key, r), r;
  11. };
  12. var BABYLON;
  13. (function (BABYLON) {
  14. var Rectangle2DRenderCache = (function (_super) {
  15. __extends(Rectangle2DRenderCache, _super);
  16. function Rectangle2DRenderCache(engine, modelKey) {
  17. _super.call(this, engine, modelKey);
  18. this.effectsReady = false;
  19. this.fillVB = null;
  20. this.fillIB = null;
  21. this.fillIndicesCount = 0;
  22. this.instancingFillAttributes = null;
  23. this.effectFill = null;
  24. this.effectFillInstanced = null;
  25. this.borderVB = null;
  26. this.borderIB = null;
  27. this.borderIndicesCount = 0;
  28. this.instancingBorderAttributes = null;
  29. this.effectBorder = null;
  30. this.effectBorderInstanced = null;
  31. }
  32. Rectangle2DRenderCache.prototype.render = function (instanceInfo, context) {
  33. // Do nothing if the shader is still loading/preparing
  34. if (!this.effectsReady) {
  35. if ((this.effectFill && (!this.effectFill.isReady() || (this.effectFillInstanced && !this.effectFillInstanced.isReady()))) ||
  36. (this.effectBorder && (!this.effectBorder.isReady() || (this.effectBorderInstanced && !this.effectBorderInstanced.isReady())))) {
  37. return false;
  38. }
  39. this.effectsReady = true;
  40. }
  41. var canvas = instanceInfo.owner.owner;
  42. var engine = canvas.engine;
  43. var depthFunction = 0;
  44. if (this.effectFill && this.effectBorder) {
  45. depthFunction = engine.getDepthFunction();
  46. engine.setDepthFunctionToLessOrEqual();
  47. }
  48. var curAlphaMode = engine.getAlphaMode();
  49. if (this.effectFill) {
  50. var partIndex = instanceInfo.partIndexFromId.get(BABYLON.Shape2D.SHAPE2D_FILLPARTID.toString());
  51. var pid = context.groupInfoPartData[partIndex];
  52. if (context.renderMode !== BABYLON.Render2DContext.RenderModeOpaque) {
  53. engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE, true);
  54. }
  55. var effect = context.useInstancing ? this.effectFillInstanced : this.effectFill;
  56. engine.enableEffect(effect);
  57. engine.bindBuffersDirectly(this.fillVB, this.fillIB, [1], 4, effect);
  58. if (context.useInstancing) {
  59. if (!this.instancingFillAttributes) {
  60. this.instancingFillAttributes = this.loadInstancingAttributes(BABYLON.Shape2D.SHAPE2D_FILLPARTID, effect);
  61. }
  62. var glBuffer = context.instancedBuffers ? context.instancedBuffers[partIndex] : pid._partBuffer;
  63. var count = context.instancedBuffers ? context.instancesCount : pid._partData.usedElementCount;
  64. canvas._addDrawCallCount(1, context.renderMode);
  65. engine.updateAndBindInstancesBuffer(glBuffer, null, this.instancingFillAttributes);
  66. engine.draw(true, 0, this.fillIndicesCount, count);
  67. engine.unbindInstanceAttributes();
  68. }
  69. else {
  70. canvas._addDrawCallCount(context.partDataEndIndex - context.partDataStartIndex, context.renderMode);
  71. for (var i = context.partDataStartIndex; i < context.partDataEndIndex; i++) {
  72. this.setupUniforms(effect, partIndex, pid._partData, i);
  73. engine.draw(true, 0, this.fillIndicesCount);
  74. }
  75. }
  76. }
  77. if (this.effectBorder) {
  78. var partIndex = instanceInfo.partIndexFromId.get(BABYLON.Shape2D.SHAPE2D_BORDERPARTID.toString());
  79. var pid = context.groupInfoPartData[partIndex];
  80. if (context.renderMode !== BABYLON.Render2DContext.RenderModeOpaque) {
  81. engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE, true);
  82. }
  83. var effect = context.useInstancing ? this.effectBorderInstanced : this.effectBorder;
  84. engine.enableEffect(effect);
  85. engine.bindBuffersDirectly(this.borderVB, this.borderIB, [1], 4, effect);
  86. if (context.useInstancing) {
  87. if (!this.instancingBorderAttributes) {
  88. this.instancingBorderAttributes = this.loadInstancingAttributes(BABYLON.Shape2D.SHAPE2D_BORDERPARTID, effect);
  89. }
  90. var glBuffer = context.instancedBuffers ? context.instancedBuffers[partIndex] : pid._partBuffer;
  91. var count = context.instancedBuffers ? context.instancesCount : pid._partData.usedElementCount;
  92. canvas._addDrawCallCount(1, context.renderMode);
  93. engine.updateAndBindInstancesBuffer(glBuffer, null, this.instancingBorderAttributes);
  94. engine.draw(true, 0, this.borderIndicesCount, count);
  95. engine.unbindInstanceAttributes();
  96. }
  97. else {
  98. canvas._addDrawCallCount(context.partDataEndIndex - context.partDataStartIndex, context.renderMode);
  99. for (var i = context.partDataStartIndex; i < context.partDataEndIndex; i++) {
  100. this.setupUniforms(effect, partIndex, pid._partData, i);
  101. engine.draw(true, 0, this.borderIndicesCount);
  102. }
  103. }
  104. }
  105. engine.setAlphaMode(curAlphaMode, true);
  106. if (this.effectFill && this.effectBorder) {
  107. engine.setDepthFunction(depthFunction);
  108. }
  109. return true;
  110. };
  111. Rectangle2DRenderCache.prototype.dispose = function () {
  112. if (!_super.prototype.dispose.call(this)) {
  113. return false;
  114. }
  115. if (this.fillVB) {
  116. this._engine._releaseBuffer(this.fillVB);
  117. this.fillVB = null;
  118. }
  119. if (this.fillIB) {
  120. this._engine._releaseBuffer(this.fillIB);
  121. this.fillIB = null;
  122. }
  123. this.effectFill = null;
  124. this.effectFillInstanced = null;
  125. this.effectBorder = null;
  126. this.effectBorderInstanced = null;
  127. if (this.borderVB) {
  128. this._engine._releaseBuffer(this.borderVB);
  129. this.borderVB = null;
  130. }
  131. if (this.borderIB) {
  132. this._engine._releaseBuffer(this.borderIB);
  133. this.borderIB = null;
  134. }
  135. return true;
  136. };
  137. return Rectangle2DRenderCache;
  138. })(BABYLON.ModelRenderCache);
  139. BABYLON.Rectangle2DRenderCache = Rectangle2DRenderCache;
  140. var Rectangle2DInstanceData = (function (_super) {
  141. __extends(Rectangle2DInstanceData, _super);
  142. function Rectangle2DInstanceData(partId) {
  143. _super.call(this, partId, 1);
  144. }
  145. Object.defineProperty(Rectangle2DInstanceData.prototype, "properties", {
  146. get: function () {
  147. return null;
  148. },
  149. enumerable: true,
  150. configurable: true
  151. });
  152. __decorate([
  153. BABYLON.instanceData()
  154. ], Rectangle2DInstanceData.prototype, "properties", null);
  155. return Rectangle2DInstanceData;
  156. })(BABYLON.Shape2DInstanceData);
  157. BABYLON.Rectangle2DInstanceData = Rectangle2DInstanceData;
  158. var Rectangle2D = (function (_super) {
  159. __extends(Rectangle2D, _super);
  160. /**
  161. * Create an Rectangle 2D Shape primitive. May be a sharp rectangle (with sharp corners), or a rounded one.
  162. * @param settings a combination of settings, possible ones are
  163. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  164. * - children: an array of direct children
  165. * - id a text identifier, for information purpose
  166. * - position: the X & Y positions relative to its parent. Alternatively the x and y settings can be set. Default is [0;0]
  167. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  168. * - scale: the initial scale of the primitive. default is 1. You can alternatively use scaleX &| scaleY to apply non uniform scale
  169. * - opacity: set the overall opacity of the primitive, 1 to be opaque (default), less than 1 to be transparent.
  170. * - zOrder: override the zOrder with the specified value
  171. * - origin: define the normalized origin point location, default [0.5;0.5]
  172. * - size: the size of the group. Alternatively the width and height settings can be set. Default will be [10;10].
  173. * - roundRadius: if the rectangle has rounded corner, set their radius, default is 0 (to get a sharp edges rectangle).
  174. * - fill: the brush used to draw the fill content of the rectangle, you can set null to draw nothing (but you will have to set a border brush), default is a SolidColorBrush of plain white. can also be a string value (see Canvas2D.GetBrushFromString)
  175. * - border: the brush used to draw the border of the rectangle, you can set null to draw nothing (but you will have to set a fill brush), default is null. can also be a string value (see Canvas2D.GetBrushFromString)
  176. * - borderThickness: the thickness of the drawn border, default is 1.
  177. * - isVisible: true if the primitive must be visible, false for hidden. Default is true.
  178. * - childrenFlatZOrder: if true all the children (direct and indirect) will share the same Z-Order. Use this when there's a lot of children which don't overlap. The drawing order IS NOT GUARANTED!
  179. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  180. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  181. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  182. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  183. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  184. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  185. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  186. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  187. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  188. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  189. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  190. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  191. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  192. */
  193. function Rectangle2D(settings) {
  194. // Avoid checking every time if the object exists
  195. if (settings == null) {
  196. settings = {};
  197. }
  198. _super.call(this, settings);
  199. if (settings.size != null) {
  200. this.size = settings.size;
  201. }
  202. else if (settings.width || settings.height) {
  203. var size = new BABYLON.Size(settings.width, settings.height);
  204. this.size = size;
  205. }
  206. //let size = settings.size || (new Size((settings.width === null) ? null : (settings.width || 10), (settings.height === null) ? null : (settings.height || 10)));
  207. var roundRadius = (settings.roundRadius == null) ? 0 : settings.roundRadius;
  208. var borderThickness = (settings.borderThickness == null) ? 1 : settings.borderThickness;
  209. //this.size = size;
  210. this.roundRadius = roundRadius;
  211. this.borderThickness = borderThickness;
  212. }
  213. Object.defineProperty(Rectangle2D.prototype, "actualSize", {
  214. get: function () {
  215. if (this._actualSize) {
  216. return this._actualSize;
  217. }
  218. return this.size;
  219. },
  220. set: function (value) {
  221. this._actualSize = value;
  222. },
  223. enumerable: true,
  224. configurable: true
  225. });
  226. Object.defineProperty(Rectangle2D.prototype, "notRounded", {
  227. get: function () {
  228. return this._notRounded;
  229. },
  230. set: function (value) {
  231. this._notRounded = value;
  232. },
  233. enumerable: true,
  234. configurable: true
  235. });
  236. Object.defineProperty(Rectangle2D.prototype, "roundRadius", {
  237. get: function () {
  238. return this._roundRadius;
  239. },
  240. set: function (value) {
  241. this._roundRadius = value;
  242. this.notRounded = value === 0;
  243. this._positioningDirty();
  244. },
  245. enumerable: true,
  246. configurable: true
  247. });
  248. Rectangle2D.prototype.levelIntersect = function (intersectInfo) {
  249. // If we got there it mean the boundingInfo intersection succeed, if the rectangle has not roundRadius, it means it succeed!
  250. if (this.notRounded) {
  251. return true;
  252. }
  253. // If we got so far it means the bounding box at least passed, so we know it's inside the bounding rectangle, but it can be outside the roundedRectangle.
  254. // The easiest way is to check if the point is inside on of the four corners area (a little square of roundRadius size at the four corners)
  255. // If it's the case for one, check if the mouse is located in the quarter that we care about (the one who is visible) then finally make a distance check with the roundRadius radius to see if it's inside the circle quarter or outside.
  256. // First let remove the origin out the equation, to have the rectangle with an origin at bottom/left
  257. var size = this.size;
  258. Rectangle2D._i0.x = intersectInfo._localPickPosition.x;
  259. Rectangle2D._i0.y = intersectInfo._localPickPosition.y;
  260. var rr = this.roundRadius;
  261. var rrs = rr * rr;
  262. // Check if the point is in the bottom/left quarter area
  263. Rectangle2D._i1.x = rr;
  264. Rectangle2D._i1.y = rr;
  265. if (Rectangle2D._i0.x <= Rectangle2D._i1.x && Rectangle2D._i0.y <= Rectangle2D._i1.y) {
  266. // Compute the intersection point in the quarter local space
  267. Rectangle2D._i2.x = Rectangle2D._i0.x - Rectangle2D._i1.x;
  268. Rectangle2D._i2.y = Rectangle2D._i0.y - Rectangle2D._i1.y;
  269. // It's a hit if the squared distance is less/equal to the squared radius of the round circle
  270. return Rectangle2D._i2.lengthSquared() <= rrs;
  271. }
  272. // Check if the point is in the top/left quarter area
  273. Rectangle2D._i1.x = rr;
  274. Rectangle2D._i1.y = size.height - rr;
  275. if (Rectangle2D._i0.x <= Rectangle2D._i1.x && Rectangle2D._i0.y >= Rectangle2D._i1.y) {
  276. // Compute the intersection point in the quarter local space
  277. Rectangle2D._i2.x = Rectangle2D._i0.x - Rectangle2D._i1.x;
  278. Rectangle2D._i2.y = Rectangle2D._i0.y - Rectangle2D._i1.y;
  279. // It's a hit if the squared distance is less/equal to the squared radius of the round circle
  280. return Rectangle2D._i2.lengthSquared() <= rrs;
  281. }
  282. // Check if the point is in the top/right quarter area
  283. Rectangle2D._i1.x = size.width - rr;
  284. Rectangle2D._i1.y = size.height - rr;
  285. if (Rectangle2D._i0.x >= Rectangle2D._i1.x && Rectangle2D._i0.y >= Rectangle2D._i1.y) {
  286. // Compute the intersection point in the quarter local space
  287. Rectangle2D._i2.x = Rectangle2D._i0.x - Rectangle2D._i1.x;
  288. Rectangle2D._i2.y = Rectangle2D._i0.y - Rectangle2D._i1.y;
  289. // It's a hit if the squared distance is less/equal to the squared radius of the round circle
  290. return Rectangle2D._i2.lengthSquared() <= rrs;
  291. }
  292. // Check if the point is in the bottom/right quarter area
  293. Rectangle2D._i1.x = size.width - rr;
  294. Rectangle2D._i1.y = rr;
  295. if (Rectangle2D._i0.x >= Rectangle2D._i1.x && Rectangle2D._i0.y <= Rectangle2D._i1.y) {
  296. // Compute the intersection point in the quarter local space
  297. Rectangle2D._i2.x = Rectangle2D._i0.x - Rectangle2D._i1.x;
  298. Rectangle2D._i2.y = Rectangle2D._i0.y - Rectangle2D._i1.y;
  299. // It's a hit if the squared distance is less/equal to the squared radius of the round circle
  300. return Rectangle2D._i2.lengthSquared() <= rrs;
  301. }
  302. // At any other locations the point is guarantied to be inside
  303. return true;
  304. };
  305. Rectangle2D.prototype.updateLevelBoundingInfo = function () {
  306. BABYLON.BoundingInfo2D.CreateFromSizeToRef(this.actualSize, this._levelBoundingInfo);
  307. };
  308. Rectangle2D.prototype.createModelRenderCache = function (modelKey) {
  309. var renderCache = new Rectangle2DRenderCache(this.owner.engine, modelKey);
  310. return renderCache;
  311. };
  312. Rectangle2D.prototype.setupModelRenderCache = function (modelRenderCache) {
  313. var renderCache = modelRenderCache;
  314. var engine = this.owner.engine;
  315. // Need to create WebGL resources for fill part?
  316. if (this.fill) {
  317. var vbSize = ((this.notRounded ? 1 : Rectangle2D.roundSubdivisions) * 4) + 1;
  318. var vb = new Float32Array(vbSize);
  319. for (var i = 0; i < vbSize; i++) {
  320. vb[i] = i;
  321. }
  322. renderCache.fillVB = engine.createVertexBuffer(vb);
  323. var triCount = vbSize - 1;
  324. var ib = new Float32Array(triCount * 3);
  325. for (var i = 0; i < triCount; i++) {
  326. ib[i * 3 + 0] = 0;
  327. ib[i * 3 + 2] = i + 1;
  328. ib[i * 3 + 1] = i + 2;
  329. }
  330. ib[triCount * 3 - 2] = 1;
  331. renderCache.fillIB = engine.createIndexBuffer(ib);
  332. renderCache.fillIndicesCount = triCount * 3;
  333. // Get the instanced version of the effect, if the engine does not support it, null is return and we'll only draw on by one
  334. var ei = this.getDataPartEffectInfo(BABYLON.Shape2D.SHAPE2D_FILLPARTID, ["index"], true);
  335. if (ei) {
  336. renderCache.effectFillInstanced = engine.createEffect("rect2d", ei.attributes, ei.uniforms, [], ei.defines, null);
  337. }
  338. // Get the non instanced version
  339. ei = this.getDataPartEffectInfo(BABYLON.Shape2D.SHAPE2D_FILLPARTID, ["index"], false);
  340. renderCache.effectFill = engine.createEffect("rect2d", ei.attributes, ei.uniforms, [], ei.defines, null);
  341. }
  342. // Need to create WebGL resource for border part?
  343. if (this.border) {
  344. var vbSize = (this.notRounded ? 1 : Rectangle2D.roundSubdivisions) * 4 * 2;
  345. var vb = new Float32Array(vbSize);
  346. for (var i = 0; i < vbSize; i++) {
  347. vb[i] = i;
  348. }
  349. renderCache.borderVB = engine.createVertexBuffer(vb);
  350. var triCount = vbSize;
  351. var rs = triCount / 2;
  352. var ib = new Float32Array(triCount * 3);
  353. for (var i = 0; i < rs; i++) {
  354. var r0 = i;
  355. var r1 = (i + 1) % rs;
  356. ib[i * 6 + 0] = rs + r1;
  357. ib[i * 6 + 1] = rs + r0;
  358. ib[i * 6 + 2] = r0;
  359. ib[i * 6 + 3] = r1;
  360. ib[i * 6 + 4] = rs + r1;
  361. ib[i * 6 + 5] = r0;
  362. }
  363. renderCache.borderIB = engine.createIndexBuffer(ib);
  364. renderCache.borderIndicesCount = triCount * 3;
  365. // Get the instanced version of the effect, if the engine does not support it, null is return and we'll only draw on by one
  366. var ei = this.getDataPartEffectInfo(BABYLON.Shape2D.SHAPE2D_BORDERPARTID, ["index"], true);
  367. if (ei) {
  368. renderCache.effectBorderInstanced = engine.createEffect("rect2d", ei.attributes, ei.uniforms, [], ei.defines, null);
  369. }
  370. // Get the non instanced version
  371. ei = this.getDataPartEffectInfo(BABYLON.Shape2D.SHAPE2D_BORDERPARTID, ["index"], false);
  372. renderCache.effectBorder = engine.createEffect("rect2d", ei.attributes, ei.uniforms, [], ei.defines, null);
  373. }
  374. return renderCache;
  375. };
  376. // We override this method because if there's a roundRadius set, we will reduce the initial Content Area to make sure the computed area won't intersect with the shape contour. The formula is simple: we shrink the incoming size by the amount of the roundRadius
  377. Rectangle2D.prototype._getInitialContentAreaToRef = function (primSize, initialContentPosition, initialContentArea) {
  378. // Fall back to default implementation if there's no round Radius
  379. if (this._notRounded) {
  380. _super.prototype._getInitialContentAreaToRef.call(this, primSize, initialContentPosition, initialContentArea);
  381. }
  382. else {
  383. var rr = Math.round((this.roundRadius - (this.roundRadius / Math.sqrt(2))) * 1.3);
  384. initialContentPosition.x = initialContentPosition.y = rr;
  385. initialContentArea.width = Math.max(0, primSize.width - (rr * 2));
  386. initialContentArea.height = Math.max(0, primSize.height - (rr * 2));
  387. }
  388. };
  389. Rectangle2D.prototype._getActualSizeFromContentToRef = function (primSize, newPrimSize) {
  390. // Fall back to default implementation if there's no round Radius
  391. if (this._notRounded) {
  392. _super.prototype._getActualSizeFromContentToRef.call(this, primSize, newPrimSize);
  393. }
  394. else {
  395. var rr = Math.round((this.roundRadius - (this.roundRadius / Math.sqrt(2))) * 1.3);
  396. newPrimSize.copyFrom(primSize);
  397. newPrimSize.width += rr * 2;
  398. newPrimSize.height += rr * 2;
  399. }
  400. };
  401. Rectangle2D.prototype.createInstanceDataParts = function () {
  402. var res = new Array();
  403. if (this.border) {
  404. res.push(new Rectangle2DInstanceData(BABYLON.Shape2D.SHAPE2D_BORDERPARTID));
  405. }
  406. if (this.fill) {
  407. res.push(new Rectangle2DInstanceData(BABYLON.Shape2D.SHAPE2D_FILLPARTID));
  408. }
  409. return res;
  410. };
  411. Rectangle2D.prototype.refreshInstanceDataPart = function (part) {
  412. if (!_super.prototype.refreshInstanceDataPart.call(this, part)) {
  413. return false;
  414. }
  415. if (part.id === BABYLON.Shape2D.SHAPE2D_BORDERPARTID) {
  416. var d = part;
  417. var size = this.actualSize;
  418. d.properties = new BABYLON.Vector3(size.width, size.height, this.roundRadius || 0);
  419. }
  420. else if (part.id === BABYLON.Shape2D.SHAPE2D_FILLPARTID) {
  421. var d = part;
  422. var size = this.actualSize;
  423. d.properties = new BABYLON.Vector3(size.width, size.height, this.roundRadius || 0);
  424. }
  425. return true;
  426. };
  427. Rectangle2D._i0 = BABYLON.Vector2.Zero();
  428. Rectangle2D._i1 = BABYLON.Vector2.Zero();
  429. Rectangle2D._i2 = BABYLON.Vector2.Zero();
  430. Rectangle2D.roundSubdivisions = 16;
  431. __decorate([
  432. BABYLON.instanceLevelProperty(BABYLON.Shape2D.SHAPE2D_PROPCOUNT + 1, function (pi) { return Rectangle2D.actualSizeProperty = pi; }, false, true)
  433. ], Rectangle2D.prototype, "actualSize", null);
  434. __decorate([
  435. BABYLON.modelLevelProperty(BABYLON.Shape2D.SHAPE2D_PROPCOUNT + 2, function (pi) { return Rectangle2D.notRoundedProperty = pi; })
  436. ], Rectangle2D.prototype, "notRounded", null);
  437. __decorate([
  438. BABYLON.instanceLevelProperty(BABYLON.Shape2D.SHAPE2D_PROPCOUNT + 3, function (pi) { return Rectangle2D.roundRadiusProperty = pi; })
  439. ], Rectangle2D.prototype, "roundRadius", null);
  440. Rectangle2D = __decorate([
  441. BABYLON.className("Rectangle2D")
  442. ], Rectangle2D);
  443. return Rectangle2D;
  444. })(BABYLON.Shape2D);
  445. BABYLON.Rectangle2D = Rectangle2D;
  446. })(BABYLON || (BABYLON = {}));