Skip to content

Commit 5d89ae1

Browse files
ChauChau
Chau
authored and
Chau
committed
fix(core): set check when resolve pierced props
1 parent f7ad3cc commit 5d89ae1

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

apps/examples/src/app/soba/skydiving/skydiver.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,8 @@ export class Skydiver {
140140

141141
beforeRender(({ clock }) => {
142142
const skydiver = this.gltf.value()?.nodes?.skydiver_2;
143-
if (skydiver?.material.uniforms?.['uTime']) {
144-
skydiver.material.uniforms['uTime'].value = clock.elapsedTime;
145-
}
143+
const timeUniform = skydiver?.material.uniforms?.['uTime'];
144+
if (timeUniform) timeUniform.value = clock.elapsedTime;
146145
});
147146
}
148147
}

libs/core/src/lib/utils/apply-props.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,20 @@ export function resolveInstanceKey(instance: any, key: string): { root: any; tar
4040
if (!key.includes('.')) return { root: instance, targetKey: key, targetProp };
4141

4242
// Resolve pierced target
43-
const chain = key.split('.');
44-
targetProp = chain.reduce((acc, part) => acc[part], instance);
45-
const targetKey = chain.pop()!;
46-
47-
// Switch root if atomic
48-
if (!targetProp?.set) instance = chain.reduce((acc, part) => acc[part], instance);
49-
50-
return { root: instance, targetKey, targetProp };
43+
targetProp = instance;
44+
for (const part of key.split('.')) {
45+
key = part;
46+
instance = targetProp;
47+
targetProp = targetProp[key];
48+
}
49+
// const chain = key.split('.');
50+
// targetProp = chain.reduce((acc, part) => acc[part], instance);
51+
// const targetKey = chain.pop()!;
52+
//
53+
// // Switch root if atomic
54+
// if (!targetProp?.set) instance = chain.reduce((acc, part) => acc[part], instance);
55+
56+
return { root: instance, targetKey: key, targetProp };
5157
}
5258

5359
// This function applies a set of changes to the instance

0 commit comments

Comments
 (0)