Skip to content

Commit 79a73ea

Browse files
committed
fix(plugin): update gltf and init generator
1 parent eaebba0 commit 79a73ea

File tree

6 files changed

+21
-25
lines changed

6 files changed

+21
-25
lines changed

apps/examples/src/app/soba/backdrop-cable/astronaut.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ export class Astronaut {
8484
});
8585

8686
const objectEvents = inject(NgtObjectEvents, { host: true });
87-
effect(() => {
88-
const model = this.modelRef()?.nativeElement;
89-
if (!model) return;
90-
91-
objectEvents.ngtObjectEvents.set(model);
92-
});
87+
objectEvents.ngtObjectEvents.set(this.modelRef);
9388
}
9489
}

apps/examples/src/app/soba/backdrop-cable/scene.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { Spaceship } from './spaceship';
3232
3333
<ngts-float [options]="{ scale: 0.75, position: [0, 0.65, 0], rotation: [0, 0.6, 0] }">
3434
<ngts-pivot-controls [options]="{ anchor: [0, 0.7, 0], depthTest: true, scale: 0.5, lineWidth: 2 }">
35-
<app-spaceship />
35+
<app-spaceship (click)="onClick()" />
3636
</ngts-pivot-controls>
3737
</ngts-float>
3838
@@ -82,4 +82,8 @@ export class SceneGraph {
8282

8383
private spaceship = viewChild.required(Spaceship);
8484
protected spaceshipModelRef = computed(() => this.spaceship().modelRef());
85+
86+
onClick() {
87+
console.log('Spaceship clicked!');
88+
}
8589
}

apps/examples/src/app/soba/backdrop-cable/spaceship.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ export class Spaceship {
106106
});
107107

108108
const objectEvents = inject(NgtObjectEvents, { host: true });
109-
effect(() => {
110-
const model = this.modelRef()?.nativeElement;
111-
if (!model) return;
112-
113-
objectEvents.ngtObjectEvents.set(model);
114-
});
109+
objectEvents.ngtObjectEvents.set(this.modelRef);
115110
}
116111
}

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import type * as THREE from 'three';
99
import { Group<%= threeImports %> } from 'three';
10-
import { extend, type NgtThreeElements, NgtObjectEvents<% if (args) { %>, NgtArgs<% } %> } from 'angular-three';
11-
import { Component, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, input, viewChild, ElementRef, inject, effect<% if (animations.length) { %>, model<% } %> } from '@angular/core';
10+
import { extend, type NgtThreeElements, NgtElementEvents, NgtObjectEvents<% if (args) { %>, NgtArgs<% } %> } from 'angular-three';
11+
import { Component, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, input, viewChild, ElementRef, inject<% if (animations.length) { %>, effect, model<% } %> } from '@angular/core';
1212
import { gltfResource } from 'angular-three-soba/loaders';
1313
import type { GLTF } from 'three-stdlib';<% if (animations.length) { %>
1414
import { animations, type NgtsAnimationClips, type NgtsAnimationApi } from 'angular-three-soba/misc';<% } %><% if (perspective) { %>
@@ -58,6 +58,10 @@ export type <%= gltfResultTypeName %> = GLTF & {
5858
directive: NgtObjectEvents,
5959
outputs: ['click', 'dblclick', 'contextmenu', 'pointerup', 'pointerdown', 'pointerover', 'pointerout', 'pointerenter', 'pointerleave', 'pointermove', 'pointermissed', 'pointercancel', 'wheel'],
6060
},
61+
{
62+
directive: NgtElementEvents,
63+
outputs: ['attached', 'updated', 'created', 'disposed']
64+
}
6165
],<% if (angularImports.length) { %>
6266
imports: [<% angularImports.join(', ') %>]<% } %>
6367
})
@@ -83,11 +87,9 @@ export class <%= className %> {
8387
<% } %>
8488

8589
const objectEvents = inject(NgtObjectEvents, { host: true });
86-
effect(() => {
87-
const model = this.modelRef()?.nativeElement;
88-
if (!model) return;
90+
const elementEvents = inject(NgtElementEvents, { host: true });
8991

90-
objectEvents.ngtObjectEvents.set(model);
91-
});
92+
objectEvents.ngtObjectEvents.set(this.modelRef);
93+
elementEvents.ngtElementEvents.set(this.modelRef);
9294
}
9395
}

libs/plugin/src/generators/init/files/scene-graph.ts__tmpl__

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CUSTOM_ELEMENTS_SCHEMA, Component, viewChild, ElementRef, ChangeDetectionStrategy } from '@angular/core';
2-
import { extend, injectBeforeRender } from 'angular-three';
2+
import { extend, beforeRender } from 'angular-three';
33
import { Mesh, BoxGeometry, MeshBasicMaterial } from 'three';
44

55
@Component({
@@ -19,7 +19,7 @@ export class SceneGraph {
1919
constructor() {
2020
extend({ Mesh, BoxGeometry, MeshBasicMaterial });
2121

22-
injectBeforeRender(({ delta }) => {
22+
beforeRender(({ delta }) => {
2323
const mesh = this.meshRef().nativeElement;
2424
mesh.rotation.x += delta;
2525
mesh.rotation.y += delta;

libs/plugin/src/versions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const ANGULAR_THREE_VERSION = 'next';
2-
export const THREE_VERSION = '^0.173.0';
3-
export const THREE_TYPE_VERSION = '^0.173.0';
4-
export const NGXTENSION_VERSION = '^4.0.0';
2+
export const THREE_VERSION = '^0.178.0';
3+
export const THREE_TYPE_VERSION = '^0.178.0';
4+
export const NGXTENSION_VERSION = '^5.0.0';
55

66
export const PEER_DEPENDENCIES: Record<string, Record<string, string>> = {
77
'angular-three-soba': {

0 commit comments

Comments
 (0)