Created
December 18, 2024 18:23
-
-
Save eurobob/fb2172ea3de34d9dc5012aa155ed59ed to your computer and use it in GitHub Desktop.
dumb code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var body: some View { | |
| RealityView { content in | |
| // Create the sphere entity | |
| guard let gooey = try? await Entity(named: "Gooey", in: realityKitContentBundle) else { | |
| fatalError("Cannot load model") | |
| } | |
| if let sphere = gooey.findEntity(named: "Sphere") { | |
| if let modelComponent = sphere.components[ModelComponent.self] { | |
| let materials = modelComponent.materials | |
| if let materialIndex = materials.firstIndex(where: { ($0 as? ShaderGraphMaterial)?.name == "Goo" }) { | |
| let material = materials[materialIndex] | |
| if var gooMaterial = materials[materialIndex] as? ShaderGraphMaterial { | |
| let velocityMatrix = simd_float3x3( | |
| SIMD3<Float>(10.0, 0.0, 0.0), | |
| SIMD3<Float>(0.0, 0.0, 0.0), | |
| SIMD3<Float>(0.0, 0.0, 0.0) | |
| ) | |
| try? gooMaterial.setParameter( | |
| name: "velocity", | |
| value: MaterialParameters.Value.float3x3(velocityMatrix) | |
| ) | |
| } | |
| } else { | |
| print("No goo material found") | |
| } | |
| } else { | |
| print("Entity 'Sphere' does not have ModelComponent") | |
| } | |
| } else { | |
| print("Entity 'Gooey' does not have ModelComponent") | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment