Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 错误:不允许从场景中删除场景的根节点_Ios_Swift_Runtime Error_Scenekit - Fatal编程技术网

Ios 错误:不允许从场景中删除场景的根节点

Ios 错误:不允许从场景中删除场景的根节点,ios,swift,runtime-error,scenekit,Ios,Swift,Runtime Error,Scenekit,代码的最后一行出现错误 - (SCNScene *)getWorkingScene { SCNScene *workingSceneView = self.scene; if (workingSceneView == nil){ workingSceneView = [[SCNScene alloc] init]; workingSceneView.background.contents = self.skyColor; sel

代码的最后一行出现错误

- (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];

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

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


一种解决方案是将
节点的所有子节点移动到
工作场景。rootNode
节点只能属于一个场景,就像一个视图只能有一个父视图一样

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

一种解决方案是将
节点的所有子节点移动到
工作场景.rootNode