# Redundant getFloatData in Geometry.setVerticesBuffer

**URL:** <https://forum.babylonjs.com/t/redundant-getfloatdata-in-geometry-setverticesbuffer/60063>\
**Category:** Questions\
**Tags:** performance, geometry, gltffileloader\
**Created:** [August 14, 2025, 8:00am UTC](https://forum.babylonjs.com/t/redundant-getfloatdata-in-geometry-setverticesbuffer/60063 "2025-08-14T08:00:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [August 14, 2025, 8:00am UTC](https://forum.babylonjs.com/t/redundant-getfloatdata-in-geometry-setverticesbuffer/60063/1 "2025-08-14T08:00:05Z")

</div>

## Background

Currently in Geometry.setVerticesBuffer, it called `this._updateExtend(buffer.getFloatData(this._totalVertices));`, if setting a position buffer.

> <https://github.com/BabylonJS/Babylon.js/blob/ed49e7d270c11ac308316b52414e59bea790edb1/packages/dev/core/src/Meshes/geometry.ts#L313>

But the result of getFloatData is ignored, if `this.useBoundingInfoFromGeometry && this._boundingInfo`, which is true if the mesh is imported from gltf loader.

> <https://github.com/BabylonJS/Babylon.js/blob/ed49e7d270c11ac308316b52414e59bea790edb1/packages/dev/core/src/Meshes/geometry.ts#L767>

And `getFloatData` is a CPU and RAM heavy call, which costs ~27% of the CPU time of loading a gltf model in sandbox, and a Major GC.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/3/d394d938f5fb1e89702af759600b21c3200495aa.png)

## Proposal

Lift the check in `_updateExtend` to `setVerticesBuffer`

```diff
diff --git a/packages/dev/core/src/Meshes/geometry.ts b/packages/dev/core/src/Meshes/geometry.ts
index 412ef07e3d..9bbc327d7d 100644
--- a/packages/dev/core/src/Meshes/geometry.ts
+++ b/packages/dev/core/src/Meshes/geometry.ts
@@ -310,7 +310,7 @@ export class Geometry implements IGetSetVerticesData {
         if (kind === VertexBuffer.PositionKind) {
             this._totalVertices = totalVertices ?? buffer._maxVerticesCount;

- this._updateExtend(buffer.getFloatData(this._totalVertices));
+ this._updateExtend(this.useBoundingInfoFromGeometry && this._boundingInfo ? null : buffer.getFloatData(this._totalVertices));
             this._resetPointsArrayCache();

             // this._extend can be empty if buffer.getFloatData(this._totalVertices) returned null

```

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [August 14, 2025, 2:57pm UTC](https://forum.babylonjs.com/t/redundant-getfloatdata-in-geometry-setverticesbuffer/60063/2 "2025-08-14T14:57:24Z")

</div>

YES! Totally! Excellent find!

Please author a PR so you can be remembered forever in the indestructible memory of github 😃

---

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [August 15, 2025, 12:42am UTC](https://forum.babylonjs.com/t/redundant-getfloatdata-in-geometry-setverticesbuffer/60063/3 "2025-08-15T00:42:35Z")

</div>

Here it is:

> <https://github.com/BabylonJS/Babylon.js/pull/17031>
>
> The \`setVerticesBuffer\` method currently unconditionally calls \`buffer.getFloatD…ata\` when setting a position buffer. However, if \`useBoundingInfoFromGeometry\` is true and \`\_boundingInfo\` is already set (a common scenario for glTF models), the data returned by \`getFloatData\` is ignored within the \`\_updateExtend\` method.
> 
> This \`getFloatData\` operation is profiled to be CPU and RAM intensive, contributing significantly to model loading times and potentially causing major garbage collection events.
> 
> This change optimizes performance by conditionally calling \`buffer.getFloatData\`. It now passes \`null\` to \`\_updateExtend\` when \`useBoundingInfoFromGeometry\` is true and \`\_boundingInfo\` exists, ensuring the expensive data retrieval is only performed when its result is actually needed and used. This will improve loading performance and reduce GC pressure, particularly for glTF assets.
> 
> Forum post: \<https://forum.babylonjs.com/t/redundant-getfloatdata-in-geometry-setverticesbuffer/60063\>

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [August 15, 2025, 4:19pm UTC](https://forum.babylonjs.com/t/redundant-getfloatdata-in-geometry-setverticesbuffer/60063/4 "2025-08-15T16:19:31Z")

</div>

Just one formatting issue and we can merge

---

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [August 16, 2025, 12:25am UTC](https://forum.babylonjs.com/t/redundant-getfloatdata-in-geometry-setverticesbuffer/60063/5 "2025-08-16T00:25:20Z")

</div>

I saw the CI log but failed to find the detailed info about the exact formatting err. Also I can not reproduce in my local repo with `npm run format:check`. Can you help with this?

> **[Pipelines](https://dev.azure.com/babylonjs/ContinousIntegration/_build/results?buildId=43009&view=logs&jobId=e7b80b24-15e8-561b-2b9b-3069817c0357&j=e7b80b24-15e8-561b-2b9b-3069817c0357&t=d44cc3c9-51e1-5b48-81c7-6e896dd5dc67)**

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [August 18, 2025, 2:47pm UTC](https://forum.babylonjs.com/t/redundant-getfloatdata-in-geometry-setverticesbuffer/60063/6 "2025-08-18T14:47:42Z")

</div>

let me check

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [August 18, 2025, 2:52pm UTC](https://forum.babylonjs.com/t/redundant-getfloatdata-in-geometry-setverticesbuffer/60063/7 "2025-08-18T14:52:56Z")

</div>

I pushed a change on the last line we ll see what happen 🙂
