Skip to content

Commit

Permalink
remove VertexBuffer import (not backwards compatible from v4->v5)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianzinn committed Aug 20, 2021
1 parent 4241215 commit f6121f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"typescript": "4.1.2"
},
"peerDependencies": {
"@babylonjs/core": "4.x",
"@babylonjs/gui": "4.x",
"@babylonjs/core": "4.x||>5.0.0-alpha",
"@babylonjs/gui": "4.x||>5.0.0-alpha",
"react": ">=17",
"react-dom": ">=17"
},
Expand Down
17 changes: 8 additions & 9 deletions src/extensions/DynamicTerrain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { SolidParticleSystem } from '@babylonjs/core/Particles/solidParticleSyst
import { IndicesArray, Nullable } from '@babylonjs/core/types.js';
import { Mesh } from '@babylonjs/core/Meshes/mesh.js';
import { MeshBuilder } from '@babylonjs/core/Meshes/meshBuilder.js';
import { VertexBuffer } from '@babylonjs/core/Meshes/buffer.js';
import { VertexData } from '@babylonjs/core/Meshes/mesh.vertexData.js';
import { Camera } from '@babylonjs/core/Cameras/camera.js';

Expand Down Expand Up @@ -245,10 +244,10 @@ import { Camera } from '@babylonjs/core/Cameras/camera.js';
}
this._terrain = MeshBuilder.CreateRibbon("terrain", ribbonOptions, this._scene)
this._indices = this._terrain.getIndices()
this._positions = this._terrain.getVerticesData(VertexBuffer.PositionKind) as (number[] | Float32Array)
this._normals = this._terrain.getVerticesData(VertexBuffer.NormalKind)!
this._uvs = this._terrain.getVerticesData(VertexBuffer.UVKind)!
this._colors = this._terrain.getVerticesData(VertexBuffer.ColorKind)!
this._positions = this._terrain.getVerticesData("position") as (number[] | Float32Array); // VertexBuffer.PositionKind moved v4->v5
this._normals = this._terrain.getVerticesData("normal")!; // VertexBuffer.NormalKind moved v4->v5
this._uvs = this._terrain.getVerticesData("uv")!; // VertexBuffer.UVKind moved v4->v5
this._colors = this._terrain.getVerticesData("color")!; // VertexBuffer.ColorKind moved v4->v5
this.computeNormalsFromMap()

// update it immediatly and register the update callback function in the render loop
Expand Down Expand Up @@ -721,13 +720,13 @@ import { Camera } from '@babylonjs/core/Cameras/camera.js';
}

// ribbon update
terrain.updateVerticesData(VertexBuffer.PositionKind, positions, false, false)
terrain.updateVerticesData("position", positions, false, false); // VertexBuffer.PositionKind moved moved v4->v5
if (this._computeNormals) {
VertexData.ComputeNormals(positions, this._indices, normals)
}
terrain.updateVerticesData(VertexBuffer.NormalKind, normals, false, false)
terrain.updateVerticesData(VertexBuffer.UVKind, uvs, false, false)
terrain.updateVerticesData(VertexBuffer.ColorKind, colors, false, false)
terrain.updateVerticesData("normal", normals, false, false); // VertexBuffer.NormalKind moved v4->v5
terrain.updateVerticesData("uv", uvs, false, false); // VertexBuffer.UVKind moved moved v4->v5
terrain.updateVerticesData("color", colors, false, false); // VertexBuffer.ColorKind moved moved v4->v5
terrain._boundingInfo!.reConstruct(bbMin, bbMax, terrain._worldMatrix)
}

Expand Down

0 comments on commit f6121f5

Please sign in to comment.