Skip to content

Commit 78af987

Browse files
committed
fix(plugin): use let for nodes/materials; call generate; adjust node name
1 parent 0e5cdcc commit 78af987

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

libs/plugin/src/generators/gltf/files/__fileName__.ts__tmpl__

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export type <%= gltfResultTypeName %> = GLTF & {
4141
selector: '<%= selector %>',
4242
template: `
4343
@if (gltf(); as gltf) {
44+
@let nodes = gltf.nodes;
45+
@let materials = gltf.materials;
46+
4447
<ngt-group #model [parameters]="options()" [dispose]="null">
4548
<%= scene %>
4649

libs/plugin/src/generators/gltf/gltf.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export async function gltfGenerator(tree: Tree, options: GltfGeneratorSchema) {
5151

5252
const generateNGT = new GenerateNGT(analyzed, options);
5353

54-
const test = await generateNGT.print(analyzed.gltf.scene);
54+
const test = await generateNGT.generate();
55+
56+
console.log(test);
5557

5658
// await formatFiles(tree);
5759
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,29 @@ export class GenerateNGT {
3636
// Bail out on bones
3737
if (!bones && type === 'bone') {
3838
this.args = true;
39-
return `<ngt-primitive *args=[gltf.${node}] />\n`;
39+
return `<ngt-primitive *args=[${node}] />\n`;
4040
}
4141

4242
const ngtType = this.getAngularThreeElement(type);
4343
if (isTargetedLight(obj)) {
4444
this.args = true;
45-
return `<${ngtType} ${this.handleAngularInputs(obj)} [target]="gltf.${node}.target">
46-
<ngt-primitive *args="[gltf.${node}.target]" ${this.handleAngularInputs(obj.target)} />
45+
return `<${ngtType} ${this.handleAngularInputs(obj)} [target]="${node}.target">
46+
<ngt-primitive *args="[${node}.target]" ${this.handleAngularInputs(obj.target)} />
4747
</${ngtType}>`;
4848
}
4949

5050
// TODO: Instances are currently not supported for NGT components
5151
//
5252
if (isInstancedMesh(obj)) {
53-
const geo = `gltf.${node}.geometry`;
53+
const geo = `${node}.geometry`;
5454
const mat =
55-
'name' in obj.material ? `gltf.materials${sanitizeName(obj.material.name)}` : `gltf.${node}.material`;
55+
'name' in obj.material ? `materials${sanitizeName(obj.material.name)}` : `gltf.${node}.material`;
5656
this.args = true;
5757
result = `<ngt-instanced-mesh *args="[${geo}, ${mat}, ${!obj.count ? `gltf.${node}.count` : obj.count}]" `;
5858
} else {
5959
if (type === 'bone') {
6060
this.args = true;
61-
result = `<ngt-primitive *args="[gltf.${node}]" `;
61+
result = `<ngt-primitive *args="[${node}]" `;
6262
} else {
6363
result = `<${this.getAngularThreeElement(type)} `;
6464
}

0 commit comments

Comments
 (0)