@rtzh/engine 0.0.5 → 0.0.6

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 (121) hide show
  1. package/Build/Workers/chunk-243UEBJF.js +1045 -0
  2. package/Build/Workers/chunk-3NSMZ3XW.js +1067 -0
  3. package/Build/Workers/chunk-4DIL24GG.js +1460 -0
  4. package/Build/Workers/chunk-4FEDW3WT.js +299 -0
  5. package/Build/Workers/chunk-4SC4KVID.js +692 -0
  6. package/Build/Workers/chunk-53AFSDGM.js +37 -0
  7. package/Build/Workers/chunk-54SSO7NS.js +352 -0
  8. package/Build/Workers/chunk-5SVTAJRH.js +837 -0
  9. package/Build/Workers/chunk-5W4ISZGQ.js +1483 -0
  10. package/Build/Workers/chunk-64VDO4BW.js +114 -0
  11. package/Build/Workers/chunk-6AUSOZOL.js +476 -0
  12. package/Build/Workers/chunk-7MMYV5PM.js +288 -0
  13. package/Build/Workers/chunk-7QPQGSS3.js +57 -0
  14. package/Build/Workers/chunk-AEURJQ3B.js +73 -0
  15. package/Build/Workers/chunk-AMJRLIO3.js +414 -0
  16. package/Build/Workers/chunk-BCYABDWF.js +3514 -0
  17. package/Build/Workers/chunk-CTARL7CY.js +511 -0
  18. package/Build/Workers/chunk-DIA4J2DB.js +497 -0
  19. package/Build/Workers/chunk-E5BSDIGY.js +139 -0
  20. package/Build/Workers/chunk-EJVGOIOW.js +1317 -0
  21. package/Build/Workers/chunk-ERYOZBVC.js +171 -0
  22. package/Build/Workers/chunk-ET7LWDHA.js +58 -0
  23. package/Build/Workers/chunk-FSYQE5XE.js +55 -0
  24. package/Build/Workers/chunk-G7PGTG3P.js +387 -0
  25. package/Build/Workers/chunk-GZMTBQM2.js +1443 -0
  26. package/Build/Workers/chunk-HAR6Y2HP.js +1800 -0
  27. package/Build/Workers/chunk-HM4MH5IG.js +138 -0
  28. package/Build/Workers/chunk-IB2XQV6U.js +101 -0
  29. package/Build/Workers/chunk-IXM65GBF.js +256 -0
  30. package/Build/Workers/chunk-IYAZCFAC.js +642 -0
  31. package/Build/Workers/chunk-JRPAFYGJ.js +1054 -0
  32. package/Build/Workers/chunk-LPJHTJDQ.js +305 -0
  33. package/Build/Workers/chunk-LRW2QXMW.js +352 -0
  34. package/Build/Workers/chunk-MWN26ZEM.js +280 -0
  35. package/Build/Workers/chunk-NIWB6UMY.js +198 -0
  36. package/Build/Workers/chunk-O5QH7XD5.js +629 -0
  37. package/Build/Workers/chunk-OBM2JYMG.js +75 -0
  38. package/Build/Workers/chunk-ODZZZGXK.js +219 -0
  39. package/Build/Workers/chunk-QY55DT53.js +97 -0
  40. package/Build/Workers/chunk-R3PTQZ6H.js +44 -0
  41. package/Build/Workers/chunk-RT7PY6BH.js +2719 -0
  42. package/Build/Workers/chunk-SAD42JSM.js +102 -0
  43. package/Build/Workers/chunk-SFM3GNS2.js +682 -0
  44. package/Build/Workers/chunk-SLYUIIFB.js +455 -0
  45. package/Build/Workers/chunk-SQSWONTJ.js +241 -0
  46. package/Build/Workers/chunk-SRLJWNU2.js +368 -0
  47. package/Build/Workers/chunk-SZELHE7Q.js +163 -0
  48. package/Build/Workers/chunk-TBASKFFL.js +124 -0
  49. package/Build/Workers/chunk-TDGGEIZE.js +398 -0
  50. package/Build/Workers/chunk-U3VI26GL.js +162 -0
  51. package/Build/Workers/chunk-VLB25GGE.js +439 -0
  52. package/Build/Workers/chunk-W4DV7TAL.js +8366 -0
  53. package/Build/Workers/chunk-WFTPZ3ZX.js +788 -0
  54. package/Build/Workers/chunk-WWLWTSMV.js +55 -0
  55. package/Build/Workers/chunk-WX2ZANQC.js +940 -0
  56. package/Build/Workers/chunk-XFKTM6GN.js +2058 -0
  57. package/Build/Workers/chunk-Z5MHVJGN.js +778 -0
  58. package/Build/Workers/combineGeometry.js +24 -24
  59. package/Build/Workers/createBoxGeometry.js +18 -18
  60. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCircleGeometry.js +26 -26
  62. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  65. package/Build/Workers/createCorridorGeometry.js +29 -29
  66. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  67. package/Build/Workers/createCylinderGeometry.js +20 -20
  68. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  69. package/Build/Workers/createEllipseGeometry.js +26 -26
  70. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  71. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  73. package/Build/Workers/createFrustumGeometry.js +18 -18
  74. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  75. package/Build/Workers/createGeometry.js +24 -24
  76. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPlaneGeometry.js +16 -16
  78. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  79. package/Build/Workers/createPolygonGeometry.js +32 -32
  80. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  81. package/Build/Workers/createPolylineGeometry.js +25 -25
  82. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  84. package/Build/Workers/createRectangleGeometry.js +27 -27
  85. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  86. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  87. package/Build/Workers/createSphereGeometry.js +19 -19
  88. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  89. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  90. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  91. package/Build/Workers/createVectorTileGeometries.js +24 -24
  92. package/Build/Workers/createVectorTilePoints.js +13 -13
  93. package/Build/Workers/createVectorTilePolygons.js +22 -22
  94. package/Build/Workers/createVectorTilePolylines.js +14 -14
  95. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  96. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  97. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  98. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  99. package/Build/Workers/createWallGeometry.js +24 -24
  100. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +10 -10
  104. package/Build/Workers/gaussianSplatSorter.js +4 -4
  105. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  106. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  107. package/Build/Workers/transcodeKTX2.js +6 -6
  108. package/Build/Workers/transferTypedArrayTest.js +1 -1
  109. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  110. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  111. package/Source/Scene/Cesium3DTileset.js +4121 -4105
  112. package/Source/Scene/Model/BarycentricWireframePipelineStage.js +258 -79
  113. package/Source/Scene/Model/Model.js +3584 -3512
  114. package/Source/Scene/Model/Model3DTileContent.js +568 -568
  115. package/Source/Scene/Model/ModelRuntimePrimitive.js +391 -391
  116. package/Source/Scene/Model/WireframePipelineStage.js +122 -122
  117. package/Source/Shaders/Model/ModelFS.glsl +3 -1
  118. package/Source/Shaders/Model/ModelFS.js +3 -1
  119. package/index.d.ts +801 -773
  120. package/index.js +65 -65
  121. package/package.json +1 -1
@@ -8,6 +8,9 @@ import ModelUtility from "./ModelUtility.js";
8
8
  import PrimitiveType from "../../Core/PrimitiveType.js";
9
9
  import ShaderDestination from "../../Renderer/ShaderDestination.js";
10
10
  import VertexAttributeSemantic from "../VertexAttributeSemantic.js";
11
+ import oneTimeWarning from "../../Core/oneTimeWarning.js";
12
+ import AttributeType from "../AttributeType.js";
13
+ import Pass from "../../Renderer/Pass.js";
11
14
 
12
15
  const BarycentricWireframePipelineStage = {
13
16
  name: "BarycentricWireframePipelineStage",
@@ -20,6 +23,15 @@ BarycentricWireframePipelineStage.process = function (
20
23
  ) {
21
24
  const shaderBuilder = renderResources.shaderBuilder;
22
25
  const model = renderResources.model;
26
+ const webgl2 = frameState.context.webgl2;
27
+
28
+ if (!webgl2) {
29
+ oneTimeWarning(
30
+ "barycentric-wireframe-webgl1",
31
+ "Barycentric wireframe mode requires WebGL 2. Falling back to lines mode.",
32
+ );
33
+ return;
34
+ }
23
35
 
24
36
  const barycentricAttributeLocation = shaderBuilder.addAttribute(
25
37
  "vec3",
@@ -29,7 +41,7 @@ BarycentricWireframePipelineStage.process = function (
29
41
  shaderBuilder.addDefine(
30
42
  "HAS_BARYCENTRIC_WIREFRAME",
31
43
  undefined,
32
- ShaderDestination.FRAGMENT,
44
+ ShaderDestination.BOTH,
33
45
  );
34
46
 
35
47
  if (model.debugWireframeOverlay) {
@@ -52,16 +64,31 @@ BarycentricWireframePipelineStage.process = function (
52
64
  "u_wireframeColor",
53
65
  ShaderDestination.FRAGMENT,
54
66
  );
67
+ shaderBuilder.addUniform(
68
+ "float",
69
+ "u_wireframeFillAlpha",
70
+ ShaderDestination.FRAGMENT,
71
+ );
55
72
 
56
73
  const stageUniforms = renderResources.uniformMap;
57
74
  stageUniforms.u_wireframeWidth = function () {
58
75
  return model.debugWireframeLineWidth ?? 1.0;
59
76
  };
60
77
  stageUniforms.u_wireframeColor = function () {
61
- return defined(model.color) ? model.color : Color.WHITE;
78
+ return model.debugWireframeColor ?? Color.WHITE;
79
+ };
80
+ stageUniforms.u_wireframeFillAlpha = function () {
81
+ return defined(model._debugWireframeFillColor)
82
+ ? 1.0
83
+ : (model._debugWireframeFillAlpha ?? 1.0);
62
84
  };
63
85
 
64
- addBarycentricAttribute(
86
+ // Enable alpha blending when fillAlpha < 1.0 in preserve-original-color mode
87
+ if (!defined(model._debugWireframeFillColor) && (model._debugWireframeFillAlpha ?? 1.0) < 1.0) {
88
+ renderResources.alphaOptions.pass = Pass.TRANSLUCENT;
89
+ }
90
+
91
+ deindexGeometryAndAddBarycentric(
65
92
  renderResources,
66
93
  primitive,
67
94
  barycentricAttributeLocation,
@@ -69,108 +96,260 @@ BarycentricWireframePipelineStage.process = function (
69
96
  );
70
97
  };
71
98
 
72
- function getOriginalIndices(primitive, indices, frameState) {
73
- const positionAttribute = ModelUtility.getAttributeBySemantic(
74
- primitive,
75
- VertexAttributeSemantic.POSITION,
99
+ function getAttributeIndex(shaderBuilder, semantic, setIndex) {
100
+ return shaderBuilder.attributeLocations[semantic + "_" + (setIndex ?? 0)];
101
+ }
102
+
103
+ function getComponentsFromType(type) {
104
+ return AttributeType.getNumberOfComponents(type);
105
+ }
106
+
107
+ function extractAttributeData(attribute) {
108
+ if (!defined(attribute)) {
109
+ return undefined;
110
+ }
111
+
112
+ const typedArray = attribute.typedArray;
113
+ if (!defined(typedArray)) {
114
+ return undefined;
115
+ }
116
+
117
+ const componentDatatype = attribute.componentDatatype;
118
+ const componentsPerAttribute = getComponentsFromType(attribute.type);
119
+ const count = attribute.count;
120
+ const byteOffset = attribute.byteOffset ?? 0;
121
+ const byteStride = attribute.byteStride;
122
+ const componentSize = ComponentDatatype.getSizeInBytes(componentDatatype);
123
+ const stride = defined(byteStride) && byteStride !== 0
124
+ ? byteStride
125
+ : componentsPerAttribute * componentSize;
126
+
127
+ const result = ComponentDatatype.createTypedArray(
128
+ componentDatatype,
129
+ count * componentsPerAttribute,
76
130
  );
77
- const vertexCount = positionAttribute.count;
78
- const webgl2 = frameState.context.webgl2;
79
131
 
80
- let originalIndices;
81
- if (defined(indices)) {
82
- const indicesBuffer = indices.buffer;
83
- const indicesCount = indices.count;
84
- if (defined(indicesBuffer) && webgl2) {
85
- const useUint8Array = indicesBuffer.sizeInBytes === indicesCount;
86
- originalIndices = useUint8Array
87
- ? new Uint8Array(indicesCount)
88
- : IndexDatatype.createTypedArray(vertexCount, indicesCount);
89
-
90
- indicesBuffer.getBufferData(originalIndices);
91
- } else {
92
- originalIndices = indices.typedArray;
132
+ const baseOffset = byteOffset;
133
+ for (let i = 0; i < count; i++) {
134
+ const byteIndex = baseOffset + i * stride;
135
+ const elementIndex = byteIndex / componentSize;
136
+ for (let c = 0; c < componentsPerAttribute; c++) {
137
+ result[i * componentsPerAttribute + c] = typedArray[elementIndex + c];
138
+ }
139
+ }
140
+
141
+ return {
142
+ data: result,
143
+ count: count,
144
+ componentsPerAttribute: componentsPerAttribute,
145
+ componentDatatype: componentDatatype,
146
+ normalized: attribute.normalized,
147
+ };
148
+ }
149
+
150
+ function extractIndicesData(primitive) {
151
+ const indices = primitive.indices;
152
+ if (!defined(indices)) {
153
+ return undefined;
154
+ }
155
+
156
+ const typedArray = indices.typedArray;
157
+ if (defined(typedArray)) {
158
+ return typedArray;
159
+ }
160
+
161
+ return undefined;
162
+ }
163
+
164
+ function deindexAttributeData(
165
+ originalData,
166
+ originalIndices,
167
+ componentsPerAttribute,
168
+ componentDatatype,
169
+ ) {
170
+ const newVertexCount = originalIndices.length;
171
+ const totalComponents = newVertexCount * componentsPerAttribute;
172
+ const newData = ComponentDatatype.createTypedArray(componentDatatype, totalComponents);
173
+
174
+ for (let i = 0; i < newVertexCount; i++) {
175
+ const oldIndex = originalIndices[i];
176
+ const srcOffset = oldIndex * componentsPerAttribute;
177
+ const dstOffset = i * componentsPerAttribute;
178
+ for (let c = 0; c < componentsPerAttribute; c++) {
179
+ newData[dstOffset + c] = originalData[srcOffset + c];
93
180
  }
94
181
  }
95
- return originalIndices;
182
+
183
+ return newData;
184
+ }
185
+
186
+ function createVertexBuffer(typedArray, frameState, model) {
187
+ const buffer = Buffer.createVertexBuffer({
188
+ context: frameState.context,
189
+ typedArray: typedArray,
190
+ usage: BufferUsage.STATIC_DRAW,
191
+ });
192
+ model._pipelineResources.push(buffer);
193
+ return buffer;
96
194
  }
97
195
 
98
- function addBarycentricAttribute(
196
+ function deindexGeometryAndAddBarycentric(
99
197
  renderResources,
100
198
  primitive,
101
- attributeLocation,
199
+ barycentricAttributeLocation,
102
200
  frameState,
103
201
  ) {
104
- const positionAttribute = ModelUtility.getAttributeBySemantic(
202
+ const model = renderResources.model;
203
+ const shaderBuilder = renderResources.shaderBuilder;
204
+ const originalIndices = extractIndicesData(primitive);
205
+ const positionAttr = ModelUtility.getAttributeBySemantic(
105
206
  primitive,
106
207
  VertexAttributeSemantic.POSITION,
107
208
  );
108
- const vertexCount = positionAttribute.count;
109
- const indices = renderResources.indices;
110
- const originalIndices = getOriginalIndices(primitive, indices, frameState);
111
-
112
- const barycentricValues = new Float32Array(vertexCount * 3);
113
-
114
- if (defined(originalIndices)) {
115
- const indexCount = indices.count;
116
- const primitiveType = primitive.primitiveType;
117
-
118
- if (PrimitiveType.isTriangles(primitiveType)) {
119
- for (let i = 0; i < indexCount; i += 3) {
120
- const i0 = originalIndices[i];
121
- const i1 = originalIndices[i + 1];
122
- const i2 = originalIndices[i + 2];
123
-
124
- barycentricValues[i0 * 3] = 1.0;
125
- barycentricValues[i0 * 3 + 1] = 0.0;
126
- barycentricValues[i0 * 3 + 2] = 0.0;
127
-
128
- barycentricValues[i1 * 3] = 0.0;
129
- barycentricValues[i1 * 3 + 1] = 1.0;
130
- barycentricValues[i1 * 3 + 2] = 0.0;
131
-
132
- barycentricValues[i2 * 3] = 0.0;
133
- barycentricValues[i2 * 3 + 1] = 0.0;
134
- barycentricValues[i2 * 3 + 2] = 1.0;
135
- }
209
+
210
+ if (!defined(positionAttr)) {
211
+ return;
212
+ }
213
+
214
+ const originalVertexCount = positionAttr.count;
215
+
216
+ if (!defined(originalIndices)) {
217
+ const barycentricValues = new Float32Array(originalVertexCount * 3);
218
+ for (let i = 0; i < originalVertexCount; i += 3) {
219
+ barycentricValues[i * 3] = 1.0;
220
+ barycentricValues[i * 3 + 1] = 0.0;
221
+ barycentricValues[i * 3 + 2] = 0.0;
222
+
223
+ barycentricValues[(i + 1) * 3] = 0.0;
224
+ barycentricValues[(i + 1) * 3 + 1] = 1.0;
225
+ barycentricValues[(i + 1) * 3 + 2] = 0.0;
226
+
227
+ barycentricValues[(i + 2) * 3] = 0.0;
228
+ barycentricValues[(i + 2) * 3 + 1] = 0.0;
229
+ barycentricValues[(i + 2) * 3 + 2] = 1.0;
136
230
  }
137
- } else {
138
- for (let i = 0; i < vertexCount; i += 3) {
139
- const baseIndex = i * 3;
140
- barycentricValues[baseIndex] = 1.0;
141
- barycentricValues[baseIndex + 1] = 0.0;
142
- barycentricValues[baseIndex + 2] = 0.0;
143
-
144
- barycentricValues[baseIndex + 3] = 0.0;
145
- barycentricValues[baseIndex + 4] = 1.0;
146
- barycentricValues[baseIndex + 5] = 0.0;
147
-
148
- barycentricValues[baseIndex + 6] = 0.0;
149
- barycentricValues[baseIndex + 7] = 0.0;
150
- barycentricValues[baseIndex + 8] = 1.0;
231
+
232
+ const barycentricBuffer = createVertexBuffer(barycentricValues, frameState, model);
233
+
234
+ const barycentricAttribute = {
235
+ index: barycentricAttributeLocation,
236
+ vertexBuffer: barycentricBuffer,
237
+ count: originalVertexCount,
238
+ componentsPerAttribute: 3,
239
+ componentDatatype: ComponentDatatype.FLOAT,
240
+ offsetInBytes: 0,
241
+ strideInBytes: 0,
242
+ normalize: false,
243
+ };
244
+ renderResources.attributes.push(barycentricAttribute);
245
+ return;
246
+ }
247
+
248
+ const primitiveType = primitive.primitiveType;
249
+ if (!PrimitiveType.isTriangles(primitiveType)) {
250
+ return;
251
+ }
252
+
253
+ const newVertexCount = originalIndices.length;
254
+ const newAttributes = [];
255
+ const originalAttributes = primitive.attributes;
256
+
257
+ for (let i = 0; i < originalAttributes.length; i++) {
258
+ const attr = originalAttributes[i];
259
+ const semantic = attr.semantic;
260
+ const setIndex = attr.setIndex;
261
+
262
+ let attributeIndex;
263
+ if (semantic === VertexAttributeSemantic.POSITION) {
264
+ attributeIndex = shaderBuilder.attributeLocations.position;
265
+ } else if (semantic === VertexAttributeSemantic.NORMAL) {
266
+ attributeIndex = shaderBuilder.attributeLocations.normal;
267
+ } else if (semantic === VertexAttributeSemantic.TANGENT) {
268
+ attributeIndex = shaderBuilder.attributeLocations.tangent;
269
+ } else if (semantic === VertexAttributeSemantic.TEXCOORD) {
270
+ attributeIndex = shaderBuilder.attributeLocations["texCoord_" + setIndex];
271
+ } else if (semantic === VertexAttributeSemantic.COLOR) {
272
+ attributeIndex = shaderBuilder.attributeLocations["color_" + setIndex];
273
+ } else if (semantic === VertexAttributeSemantic.JOINTS) {
274
+ attributeIndex = shaderBuilder.attributeLocations["joints_" + setIndex];
275
+ } else if (semantic === VertexAttributeSemantic.WEIGHTS) {
276
+ attributeIndex = shaderBuilder.attributeLocations["weights_" + setIndex];
277
+ } else {
278
+ continue;
151
279
  }
280
+
281
+ if (!defined(attributeIndex)) {
282
+ continue;
283
+ }
284
+
285
+ const extracted = extractAttributeData(attr);
286
+ if (!defined(extracted)) {
287
+ continue;
288
+ }
289
+
290
+ const newData = deindexAttributeData(
291
+ extracted.data,
292
+ originalIndices,
293
+ extracted.componentsPerAttribute,
294
+ extracted.componentDatatype,
295
+ );
296
+
297
+ const newBuffer = createVertexBuffer(newData, frameState, model);
298
+
299
+ newAttributes.push({
300
+ index: attributeIndex,
301
+ vertexBuffer: newBuffer,
302
+ count: newVertexCount,
303
+ componentsPerAttribute: extracted.componentsPerAttribute,
304
+ componentDatatype: extracted.componentDatatype,
305
+ offsetInBytes: 0,
306
+ strideInBytes: 0,
307
+ normalize: extracted.normalized,
308
+ });
152
309
  }
153
310
 
154
- const barycentricBuffer = Buffer.createVertexBuffer({
155
- context: frameState.context,
156
- typedArray: barycentricValues,
157
- usage: BufferUsage.STATIC_DRAW,
158
- });
311
+ const instanceAttributes = renderResources.attributes.filter(
312
+ function (attr) {
313
+ return attr.instanceDivisor === 1;
314
+ },
315
+ );
316
+ for (let i = 0; i < instanceAttributes.length; i++) {
317
+ newAttributes.push(instanceAttributes[i]);
318
+ }
159
319
 
160
- const model = renderResources.model;
161
- model._pipelineResources.push(barycentricBuffer);
320
+ const barycentricValues = new Float32Array(newVertexCount * 3);
321
+ for (let i = 0; i < newVertexCount; i += 3) {
322
+ barycentricValues[i * 3] = 1.0;
323
+ barycentricValues[i * 3 + 1] = 0.0;
324
+ barycentricValues[i * 3 + 2] = 0.0;
325
+
326
+ barycentricValues[(i + 1) * 3] = 0.0;
327
+ barycentricValues[(i + 1) * 3 + 1] = 1.0;
328
+ barycentricValues[(i + 1) * 3 + 2] = 0.0;
162
329
 
163
- const barycentricAttribute = {
164
- index: attributeLocation,
330
+ barycentricValues[(i + 2) * 3] = 0.0;
331
+ barycentricValues[(i + 2) * 3 + 1] = 0.0;
332
+ barycentricValues[(i + 2) * 3 + 2] = 1.0;
333
+ }
334
+
335
+ const barycentricBuffer = createVertexBuffer(barycentricValues, frameState, model);
336
+
337
+ newAttributes.push({
338
+ index: barycentricAttributeLocation,
165
339
  vertexBuffer: barycentricBuffer,
340
+ count: newVertexCount,
166
341
  componentsPerAttribute: 3,
167
342
  componentDatatype: ComponentDatatype.FLOAT,
168
343
  offsetInBytes: 0,
169
344
  strideInBytes: 0,
170
345
  normalize: false,
171
- };
346
+ });
172
347
 
173
- renderResources.attributes.push(barycentricAttribute);
348
+ renderResources.attributes = newAttributes;
349
+ renderResources.indices = undefined;
350
+ renderResources.count = newVertexCount;
351
+ renderResources.primitiveType = PrimitiveType.TRIANGLES;
352
+ renderResources.wireframeIndexBuffer = undefined;
174
353
  }
175
354
 
176
355
  export default BarycentricWireframePipelineStage;