Skip to content

Commit f56549c

Browse files
Chau TranChau Tran
Chau Tran
authored and
Chau Tran
committed
feat(core): add nativeProps signal to track native properties on THREE instance
1 parent 3e92fa3 commit f56549c

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

libs/angular-three/src/lib/renderer/store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ export class NgtRendererStore {
346346

347347
delete (localState as NgtAnyRecord)['objects'];
348348
delete (localState as NgtAnyRecord)['nonObjects'];
349+
delete (localState as NgtAnyRecord)['nativeProps'];
349350
delete (localState as NgtAnyRecord)['add'];
350351
delete (localState as NgtAnyRecord)['remove'];
351352
delete (localState as NgtAnyRecord)['afterUpdate'];

libs/angular-three/src/lib/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ export type NgtInstanceLocalState = {
251251
// shortcut to add/remove object to list
252252
add: (instance: NgtInstanceNode, type: 'objects' | 'nonObjects') => void;
253253
remove: (instance: NgtInstanceNode, type: 'objects' | 'nonObjects') => void;
254+
// native props signal
255+
nativeProps: NgtSignalStore<NgtAnyRecord>;
254256
// parent based on attach three instance
255257
parent: WritableSignal<NgtInstanceNode | null>;
256258
// if this THREE instance is a ngt-primitive

libs/angular-three/src/lib/utils/apply-props.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export function applyProps(instance: NgtInstanceNode, props: NgtAnyRecord): NgtI
7979
// auto-convert srgb
8080
if (!THREE.ColorManagement && !rootState?.linear && isColor) targetProp.convertSRGBToLinear();
8181
}
82+
83+
localState?.nativeProps?.set({ [key]: targetProp });
8284
}
8385
// else just overwrite the value
8486
else {
@@ -96,6 +98,7 @@ export function applyProps(instance: NgtInstanceNode, props: NgtAnyRecord): NgtI
9698
else texture.encoding = rootState.gl.outputEncoding;
9799
}
98100
}
101+
localState?.nativeProps?.set({ [key]: value });
99102
}
100103

101104
checkUpdate(targetProp);

libs/angular-three/src/lib/utils/instance.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { untracked } from '@angular/core';
2+
import { NgtSignalStore } from '../stores/signal.store';
23
import type { NgtAnyRecord, NgtInstanceLocalState, NgtInstanceNode } from '../types';
34
import { createSignal } from './signal';
45
import { checkUpdate } from './update';
@@ -38,6 +39,7 @@ export function prepare<TInstance extends object = NgtAnyRecord>(
3839
handlers: {},
3940
objects,
4041
nonObjects,
42+
nativeProps: new NgtSignalStore({}),
4143
add: (object, type) => {
4244
const current = untracked(instance.__ngt__[type]);
4345
const foundIndex = current.indexOf((obj: NgtInstanceNode) => obj === object);

libs/soba/abstractions/src/gizmo-helper/gizmo-helper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ export class NgtsGizmoHelper extends NgtSignalStore<NgtsGizmoHelperState> {
168168
constructor() {
169169
super({ alignment: 'bottom-right', margin: [80, 80], renderPriority: 1 });
170170
this.#updateDefaultUp();
171-
console.log(this.virtualCameraRef);
172171
}
173172

174173
onBeforeRender(delta: number) {

0 commit comments

Comments
 (0)