@@ -32,9 +32,13 @@ export class glTFParser {
32
32
* Creates a new parser using the specified asset.
33
33
* @param asset The asset to parse.
34
34
* @param materialFactory The material factory to use.
35
- * @param meshoptDecoder optionally provide meshoptDecoder to parse meshopt meshes.
35
+ * @param meshoptDecoder provide meshoptimizer's meshoptDecoder to parse meshopt meshes.
36
36
*/
37
- constructor ( asset : glTFAsset , materialFactory ?: MaterialFactory , meshoptDecoder ?: any ) {
37
+ constructor (
38
+ asset : glTFAsset ,
39
+ materialFactory ?: MaterialFactory ,
40
+ meshoptDecoder ?: any
41
+ ) {
38
42
this . _asset = asset ;
39
43
this . _materialFactory = materialFactory || new StandardMaterialFactory ( ) ;
40
44
this . _descriptor = this . _asset . descriptor ;
@@ -52,7 +56,11 @@ export class glTFParser {
52
56
* @param asset The asset to create the model from.
53
57
* @param materialFactory The material factory to use.
54
58
*/
55
- static createModel ( asset : glTFAsset , materialFactory ?: MaterialFactory , meshoptDecoder ?: any ) {
59
+ static createModel (
60
+ asset : glTFAsset ,
61
+ materialFactory ?: MaterialFactory ,
62
+ meshoptDecoder ?: any
63
+ ) {
56
64
return new glTFParser ( asset , materialFactory , meshoptDecoder ) . parseModel ( ) ;
57
65
}
58
66
@@ -100,15 +108,18 @@ export class glTFParser {
100
108
let buffer = this . _asset . buffers [ bufferView . buffer ] ;
101
109
102
110
if ( bufferView . extensions ?. EXT_meshopt_compression != undefined ) {
103
-
104
- if ( this . _meshoptDecoder == undefined ) {
105
- console . error ( 'Buffer uses EXT_meshopt_compression but meshoptDecoder is not provided.' ) ;
106
- return ;
111
+ if ( this . _meshoptDecoder != undefined ) {
112
+ const meshoptExtension = bufferView . extensions . EXT_meshopt_compression ;
113
+ buffer = this . decodeMeshoptBuffer (
114
+ meshoptExtension ,
115
+ accessor . bufferView
116
+ ) ;
117
+ offset = accessor . byteOffset || 0 ;
118
+ } else {
119
+ console . error (
120
+ "Buffer uses EXT_meshopt_compression but meshoptDecoder is not provided."
121
+ ) ;
107
122
}
108
-
109
- const meshoptExtension = bufferView . extensions . EXT_meshopt_compression ;
110
- buffer = this . decodeMeshoptBuffer ( meshoptExtension , accessor . bufferView ) ;
111
- offset = accessor . byteOffset || 0 ;
112
123
}
113
124
114
125
return glTFAttribute . from (
0 commit comments