gpt4 book ai didi

ios - 错误 : removing the root node of a scene from its scene is not allowed

转载 作者:行者123 更新时间:2023-11-28 12:18:22 25 4
gpt4 key购买 nike

我在代码的最后一行遇到错误。

- (SCNScene *)getWorkingScene {
SCNScene *workingSceneView = self.scene;

if (workingSceneView == nil){
workingSceneView = [[SCNScene alloc] init];
workingSceneView.background.contents = self.skyColor;
self.scene = workingSceneView;
self.allowsCameraControl = TRUE;
self.autoenablesDefaultLighting = TRUE;
self.showsStatistics = TRUE;
self.backgroundColor = self.skyColor;
self.delegate = self;
}

return workingSceneView;
}

DPoint *point = [coodinate convertCooridnateTo3DPoint];
NSURL *pathToResource = [NSURL urlWithObjectName:objectName ofType:@"dae"];
NSError *error;
SCNScene *scene = [SCNScene sceneWithURL:pathToResource options:nil error:&error];
SCNNode *node = scene.rootNode;
node.position = SCNVector3Make(point.x, point.y, point.z);
node.rotation = SCNVector4Make(0, 1, 0, ((M_PI*point.y)/180.0));
SCNScene *workingScene = self.getWorkingScene;
[workingScene.rootNode addChildNode:node];

最佳答案

一个节点只能属于一个场景,就像一个 View 只能有一个父 View 一样。

当您调用 [workingScene.rootNode addChildNode:node]; 时,您正在将 node 从其当前场景 (scene) 移动到另一个场景场景(workingScene)。但是nodescene的根节点。不允许删除场景的根节点,因此会出现错误。

一种解决方案是将 node 的所有子节点移动到 workingScene.rootNode

关于ios - 错误 : removing the root node of a scene from its scene is not allowed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45682267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com