Post

Replies

Boosts

Views

Activity

Reply to SceneKit minimumPointScreenSpaceRadius not work
Helo Greg, I have tried setting the pointSize, but that doesn't seem to work Here is my test code: - (void)viewDidLoad { [super viewDidLoad]; self.sceneView = [[SCNView alloc] initWithFrame:self.view.frame]; self.sceneView.backgroundColor = [UIColor grayColor]; SCNScene *scene = [SCNScene new]; self.sceneView.scene = scene; self.sceneView.allowsCameraControl = YES; self.sceneView.showsStatistics = YES; [self.view addSubview:self.sceneView]; SCNNode *camNode = [SCNNode node]; camNode.name = @"cam"; camNode.camera = [SCNCamera camera]; camNode.position = SCNVector3Make(0, 0, 100); SCNCameraController *camController = [SCNCameraController new]; camController.pointOfView = camNode; camController.target = SCNVector3Zero; [self.sceneView.scene.rootNode addChildNode:camNode]; self.sceneView.pointOfView = camNode; // test cloud point NSInteger count = 10000; NSMutableData *vertexData = [NSMutableData data]; NSMutableData *colorData = [NSMutableData data]; for (int i = 0; i < count; ++i) { float x = (float)(arc4random() % 20001) / 100.0f - 100.0f; float y = (float)(arc4random() % 20001) / 100.0f - 100.0f; float z = (float)(arc4random() % 20001) / 100.0f - 100.0f; SCNVector3 point = SCNVector3Make(x / 2, y / 2, z / 2); [vertexData appendBytes:&point length:sizeof(SCNVector3)]; float r = (float)(arc4random() % 255) / 255.0f; float g = (float)(arc4random() % 255) / 255.0f; float b = (float)(arc4random() % 255) / 255.0f; [colorData appendBytes:&r length:sizeof(float)]; [colorData appendBytes:&g length:sizeof(float)]; [colorData appendBytes:&b length:sizeof(float)]; } SCNGeometrySource *vertexSource = [SCNGeometrySource geometrySourceWithData:vertexData semantic:SCNGeometrySourceSemanticVertex vectorCount:count floatComponents:YES componentsPerVector:3 bytesPerComponent:sizeof(float) dataOffset:0 dataStride:sizeof(SCNVector3)]; SCNGeometrySource *colorSource = [SCNGeometrySource geometrySourceWithData:colorData semantic:SCNGeometrySourceSemanticColor vectorCount:count floatComponents:YES componentsPerVector:3 bytesPerComponent:sizeof(float) dataOffset:0 dataStride:sizeof(SCNVector3)]; SCNGeometryElement *element = [SCNGeometryElement geometryElementWithData:nil primitiveType:SCNGeometryPrimitiveTypePoint primitiveCount:count bytesPerIndex:sizeof(int)]; element.pointSize = 10; // set a value, But it doesn't seem to work element.minimumPointScreenSpaceRadius = 1.0; element.maximumPointScreenSpaceRadius = 10.0; SCNGeometry *geometry = [SCNGeometry geometryWithSources:@[vertexSource, colorSource] elements:@[element]]; SCNNode *node = [SCNNode nodeWithGeometry:geometry]; [self.sceneView.scene.rootNode addChildNode:node]; }
Topic: Graphics & Games SubTopic: SceneKit Tags:
Apr ’25