Skip to content

Commit 8a42b40

Browse files
committed
fix(plugin): adjust generate
1 parent cf94efa commit 8a42b40

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

libs/plugin/src/generators/gltf/utils/generate-ngt.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@ export class GenerateNGT {
1212
) {}
1313

1414
async generate() {
15-
return this.analyzedGLTF.gltf.scene.children.map((child) => this.print(child)).join('\n');
15+
const gltfjsxApi = await import('@rosskevin/gltfjsx');
16+
return this.analyzedGLTF.gltf.scene.children.map((child) => this.print(child, gltfjsxApi)).join('\n');
1617
}
1718

18-
async print(obj: Object3D) {
19-
const { nodeName, isRemoved, isTargetedLight, isInstancedMesh, sanitizeName } = await import(
20-
'@rosskevin/gltfjsx'
21-
);
19+
private print(
20+
obj: Object3D,
21+
// @ts-expect-error - type only import
22+
gltfjsxApi: typeof import('@rosskevin/gltfjsx'),
23+
) {
24+
const { nodeName, isRemoved, isTargetedLight, isInstancedMesh, sanitizeName } = gltfjsxApi;
2225

2326
let result = '';
2427
let children = '';
2528

2629
// Children
27-
if (obj.children) obj.children.forEach((child) => (children += this.print(child)));
30+
if (obj.children) obj.children.forEach((child) => (children += this.print(child, gltfjsxApi)));
2831

2932
// Bail out if the object was pruned
3033
if (isRemoved(obj)) return children;

0 commit comments

Comments
 (0)