File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ var primitiveUv1Padding = 4.0 / 64;
36
36
var primitiveUv1PaddingScale = 1.0 - primitiveUv1Padding * 2 ;
37
37
38
38
// cached mesh primitives
39
- var shapePrimitiveMap = new Map ( ) ;
39
+ var shapePrimitives = [ ] ;
40
40
41
41
function calculateNormals ( positions , indices ) {
42
42
var triangleCount = indices . length / 3 ;
@@ -1063,7 +1063,15 @@ function createBox(device, opts) {
1063
1063
// returns Primitive data, used by ModelComponent and RenderComponent
1064
1064
function getShapePrimitive ( device , type ) {
1065
1065
1066
- var primData = shapePrimitiveMap . get ( type ) ;
1066
+ // find in cache
1067
+ var primData = null ;
1068
+ for ( var i = 0 ; i < shapePrimitives . length ; i ++ ) {
1069
+ if ( shapePrimitives [ i ] . type === type && shapePrimitives [ i ] . device === device ) {
1070
+ primData = shapePrimitives [ i ] . primData ;
1071
+ }
1072
+ }
1073
+
1074
+ // not in cache, create new
1067
1075
if ( ! primData ) {
1068
1076
1069
1077
var mesh , area ;
@@ -1104,7 +1112,13 @@ function getShapePrimitive(device, type) {
1104
1112
}
1105
1113
1106
1114
primData = { mesh : mesh , area : area } ;
1107
- shapePrimitiveMap . set ( type , primData ) ;
1115
+
1116
+ // add to cache
1117
+ shapePrimitives . push ( {
1118
+ type : type ,
1119
+ device : device ,
1120
+ primData : primData
1121
+ } ) ;
1108
1122
}
1109
1123
1110
1124
return primData ;
You can’t perform that action at this time.
0 commit comments