-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Hi, I wanted to know if there is a way to remove these logs [app.debug.dylib] [RNF/HybridObject]: (MEMORY) Deleting EntityWrapper (#166)... β [app.debug.dylib] [RNF/HybridObject]: (MEMORY) Creating EntityWrapper (#167)... β
when using morph targets, it gets really spammy when playing multiple morph targets at the same time/trying to smooth them out. A single click on a button to change the morph target creates at least 7 of these logs.
Here is my code, I have been following the example from MorphTargets.tsx
import React from 'react';
import { Button, View } from 'react-native';
import {
Animator,
Camera,
DefaultLight,
Entity,
FilamentView,
ModelRenderer,
useFilamentContext,
useModel,
} from 'react-native-filament';
const animationInterpolationTime = 5;
interface CharacterRendererProps {
modelUri: string;
cid: string;
}
export function CharacterRenderer({ modelUri, cid }: CharacterRendererProps) {
const model = useModel({ uri: modelUri });
const { renderableManager } = useFilamentContext();
// const {} = useCharacterAnimation(model);
const setMorphTarget = React.useCallback(
(targetName: string, weight: number) => {
if (model.state !== 'loaded') return;
const renderables = model.asset.getRenderableEntities();
renderables.forEach((entity: Entity) => {
const morphCount = model.asset.getMorphTargetCountAt(entity);
for (let i = 0; i < morphCount; i++) {
const name = model.asset.getMorphTargetNameAt(entity, i);
if (name === targetName) {
renderableManager.setMorphWeights(entity, [weight], i);
console.log(
`Set ${targetName} to ${weight} at index ${i} on entity`,
);
}
}
});
},
[model, renderableManager],
);
return (
<View style={{ flex: 1 }}>
<FilamentView style={{ flex: 1, backgroundColor: '#FDD99A' }}>
<Camera cameraPosition={[0, 1, 4]} cameraTarget={[0, 0, 0]} />
<DefaultLight />
<ModelRenderer
model={model}
scale={[0.07, 0.07, 0.07]}
translate={[0, -0.5, 0]}
castShadow={true}
receiveShadow={true}
>
<Animator
animationIndex={1}
transitionDuration={animationInterpolationTime}
onAnimationsLoaded={() => {}}
/>
</ModelRenderer>
</FilamentView>
{/* {animations.length < 1 && (
<View className="absolute bottom-0 left-0 right-0 top-0 items-center justify-center">
<Text>Loading character...</Text>
</View>
)} */}
<Button title="Open Eyes" onPress={() => setMorphTarget('blink', 1.0)} />
<Button
title="Close Eyes"
onPress={() => setMorphTarget('blink', 0.0)}
/>
</View>
);
}
Metadata
Metadata
Assignees
Labels
No labels