私はXCodeでDAEファイルをインポートし、それをSCNファイルに変換しました。このファイルには、アニメーションを含む3Dオブジェクトがいくつか含まれています。scnのアニメーション付き3Dオブジェクトをインポート
すべてのノードをアニメーションでインポートして、シーンで再生しようとしています。ノードはインポートされますが、アニメーションを再生できません。
NSURL *idleURL = [[NSBundle mainBundle] URLForResource:model.model3D
withExtension:@"scn" subdirectory:@"3d.scnassets"];
SCNScene *idleScene = [SCNScene sceneWithURL:idleURL
options:@{
SCNSceneSourceAnimationImportPolicyKey:SCNSceneSourceAnimationImportPolicyPlayRepeatedly}
error:nil];
// Merge the loaded scene into our main scene in order to
// place the object in our own scene
for (SCNNode *child in idleScene.rootNode.childNodes){
[_sceneView.scene.rootNode addChildNode:child];
if (child.animationKeys.count > 0) {
CAAnimation *animation = [child animationForKey:child.animationKeys[0]];
animation.repeatCount = INFINITY;
child.paused = NO;
[_sceneView.scene.rootNode addAnimation:animation forKey:child.animationKeys[0]];
}
}
[_sceneView setPlaying:YES];
DAEファイルを変換する前に、エンティティ - >アニメーションの下を見てください。それ以上のアニメーションキー[0]が表示されている場合は、アニメーションの一部だけになります。このような場合には、あなたのオブジェクトの痙攣を見たり、1つの箇所でわずかに動くことさえあります。すべてのアニメーションキーを1つに変換するダウンロード用のファイルがあります。これはSCNファイルに変換する前に行う必要があります。 – FlippinFun