Posts

Post not yet marked as solved
0 Replies
306 Views
I am trying to make an application for the Vision Pro where the particles don't move but rather stay still so that there is no lag. For example I am trying to spawn in a 100 particles here: I want the particles to remain static but spawning in many causes the simulator to lag. Also is there maybe a way i can get a particle system to follow a specific shape like the one i have in the image. Currently, I have multiple model entities that take on a particle system component for i in 0..<100 { let newEntity = ModelEntity() var particleSystem = particleSystem(color: newColor) newEntity.components.set(particleSystem) newEntity.position = position newEntity.scale = scale stars.append(newEntity) } } func particleSystem(color: UIColor) -> ParticleEmitterComponent { var particles = ParticleEmitterComponent() particles.emitterShapeSize = .init(repeating: 0.02) // make burst smaller particles.emitterShape = .sphere particles.mainEmitter.birthRate = 1 particles.mainEmitter.lifeSpan = 2 particles.mainEmitter.size = 0.02 particles.burstCount = 50 particles.speed = 0.01 particles.mainEmitter.isLightingEnabled = false particles.mainEmitter.color = .constant(.single(color)) return particles }
Posted
by COCO-G.
Last updated
.
Post not yet marked as solved
1 Replies
240 Views
I have an Entity from findEntity and would like to clone that entity. But the problem is I also want to add a material to that entity. I can only add materials to ModelEntities from what I have seen. Here is my code: if let pieceEntity: Entity = self.chessPieces.findEntity(named: entityName){ newEntity = pieceEntity.clone(recursive: true) pieceEntity.transform.translation = .init(repeating: 0) let newScale: SIMD3<Float> = .init(x: widthScale*universalScale, y: depthScale*universalScale, z: depthScale*universalScale) newEntity.scale = newScale let collisionComponent = CollisionComponent(shapes: [.generateBox(size: .init(x: width, y: height, z: depth))]) newEntity.components.set(collisionComponent) newEntity.components.set(InputTargetComponent()) } newEntity.model?.materials = [SimpleMaterial(color: chessPiece.color == .black ? .black : .white, isMetallic: false)] newEntity.name = chessPiece.toString()
Posted
by COCO-G.
Last updated
.
Post not yet marked as solved
2 Replies
250 Views
I have a model called ChessPiecesModel and inside this model contains pawn, king, queen, etc. models. I want to render each of these as ModelEntities but it does not render the chess pieces either This is the current code I have where i am trying to render the ChessPieesModel into a RealityView: RealityView { content in if let chessPieces = try? await ModelEntity(named: "ChessPiecesModel") { chessPieces.transform.translation = .init(x: 0, y: 0, z: 0) chessPieces.scale = .init(x: 10, y: 20, z: 20) content.add(chessPieces) } }
Posted
by COCO-G.
Last updated
.