Skip to content
Snippets Groups Projects
Commit 6fd00e31 authored by Alexander Rose's avatar Alexander Rose
Browse files

cache cylinder primitive

parent b53203e5
Branches
Tags
No related merge requests found
......@@ -45,6 +45,7 @@ export namespace MeshBuilder {
let currentId = -1
const cylinderMap = new Map<string, Primitive>()
const icosahedronMap = new Map<string, Primitive>()
const add = (t: Mat4, _vertices: Float32Array, _normals: Float32Array, _indices: Uint32Array) => {
......@@ -75,7 +76,12 @@ export namespace MeshBuilder {
return add(t, box.vertices, box.normals, box.indices)
},
addCylinder: (t: Mat4, props?: CylinderProps) => {
const cylinder = Cylinder(props)
const key = JSON.stringify(props)
let cylinder = cylinderMap.get(key)
if (cylinder === undefined) {
cylinder = Cylinder(props)
cylinderMap.set(key, cylinder)
}
return add(t, cylinder.vertices, cylinder.normals, cylinder.indices)
},
addIcosahedron: (t: Mat4, props: IcosahedronProps) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment