@@ -4,11 +4,12 @@ import { VRMFirstPersonImporter } from './firstperson';
4
4
import { VRMHumanoidImporter } from './humanoid/VRMHumanoidImporter' ;
5
5
import { VRMLookAtImporter } from './lookat/VRMLookAtImporter' ;
6
6
import { VRMMaterialImporter } from './material' ;
7
+ import { VRMMetaImporter } from './meta/VRMMetaImporter' ;
7
8
import { VRMSpringBoneImporter } from './springbone/VRMSpringBoneImporter' ;
8
- import { VRMSchema } from './types' ;
9
9
import { VRM } from './VRM' ;
10
10
11
11
export interface VRMImporterOptions {
12
+ metaImporter ?: VRMMetaImporter ;
12
13
lookAtImporter ?: VRMLookAtImporter ;
13
14
humanoidImporter ?: VRMHumanoidImporter ;
14
15
blendShapeImporter ?: VRMBlendShapeImporter ;
@@ -21,6 +22,7 @@ export interface VRMImporterOptions {
21
22
* An importer that imports a [[VRM]] from a VRM extension of a GLTF.
22
23
*/
23
24
export class VRMImporter {
25
+ protected readonly _metaImporter : VRMMetaImporter ;
24
26
protected readonly _blendShapeImporter : VRMBlendShapeImporter ;
25
27
protected readonly _lookAtImporter : VRMLookAtImporter ;
26
28
protected readonly _humanoidImporter : VRMHumanoidImporter ;
@@ -34,6 +36,7 @@ export class VRMImporter {
34
36
* @param options [[VRMImporterOptions]], optionally contains importers for each component
35
37
*/
36
38
public constructor ( options : VRMImporterOptions = { } ) {
39
+ this . _metaImporter = options . metaImporter || new VRMMetaImporter ( ) ;
37
40
this . _blendShapeImporter = options . blendShapeImporter || new VRMBlendShapeImporter ( ) ;
38
41
this . _lookAtImporter = options . lookAtImporter || new VRMLookAtImporter ( ) ;
39
42
this . _humanoidImporter = options . humanoidImporter || new VRMHumanoidImporter ( ) ;
@@ -51,8 +54,6 @@ export class VRMImporter {
51
54
if ( gltf . parser . json . extensions === undefined || gltf . parser . json . extensions . VRM === undefined ) {
52
55
throw new Error ( 'Could not find VRM extension on the GLTF' ) ;
53
56
}
54
- const vrmExt : VRMSchema . VRM = gltf . parser . json . extensions . VRM ;
55
-
56
57
const scene = gltf . scene ;
57
58
58
59
scene . updateMatrixWorld ( false ) ;
@@ -65,6 +66,8 @@ export class VRMImporter {
65
66
}
66
67
} ) ;
67
68
69
+ const meta = ( await this . _metaImporter . import ( gltf ) ) || undefined ;
70
+
68
71
const materials = ( await this . _materialImporter . convertGLTFMaterials ( gltf ) ) || undefined ;
69
72
70
73
const humanoid = ( await this . _humanoidImporter . import ( gltf ) ) || undefined ;
@@ -82,7 +85,7 @@ export class VRMImporter {
82
85
83
86
return new VRM ( {
84
87
scene : gltf . scene ,
85
- meta : vrmExt . meta ,
88
+ meta,
86
89
materials,
87
90
humanoid,
88
91
firstPerson,
0 commit comments