Try using HasModel instead of ModelEntity.
Your best bet at solving this is putting a breakpoint after setting map and having a look at the contents with Xcode's inspector.
Post
Replies
Boosts
Views
Activity
Sounds like you might want to change the properties in PhysicsMassProperties for your object when it's in dynamic mode, maybe your impulse isn't big enough.
Since iOS 15 / macOS 12 we can now add shaders in RealityKit 🎉
The entry point for these is GeometryModifier and SurfaceShader.
The usage of these is used in the Underwater code sample:
Building an Immersive Experience with RealityKit
In RealityKit the animation will always take the shortest path to get to the correct transform. This means that rotations will take the shortest distance.
If you want to force the animation to go the other way around you'll have to add two animations in sequence: the first one goes half way round the anticlockwise direction, and the second is the final transform of your entity.
This also means that you can't spin around an axis object continually without doing something similar - which is very annoying!!
Not with the builtin MultipeerConnectivityService, but you can always encode your own data to then send over a TCP connection to another device.
The collaboration data can be grabbed with session(_:didOutputCollaborationData:) - https://developer.apple.com/documentation/arkit/arsessionobserver/3152999-session then sent over your network instead.
I think if you go to any further detail then you'll need to create your own data structure for sending instructions between devices, which is certainly achievable.
+1 for attention to finer but much needed detail like this please!
Or just being able to set blend modes if that's the issue.
Make sure you import ARKit at the top of your swift file, the different AR configurations aren't included in just RealityKit:
swift
import ARKit
I would guess that the labelNode has a parent with a scale of [0.01, 0.01, 0.01].
Scale (as well as position and rotation) is inherited from the node's parent, so if a parent node has a very small scale, then even if the parent scale is increased again, the position will be multiplied by the parent's scale.
There are some methods in SceneKit to help with the maths involved in these operations such as this one:
https://developer.apple.com/documentation/scenekit/scnnode/1408018-convertposition
And you can set the worldPosition of a node too
https://developer.apple.com/documentation/scenekit/scnnode/2867405-worldposition
You can get the CVPixelBuffer from arView.session.currentFrame?.capturedImage, which comes without any Entities shown.
From there you can convert to whatever format you like, Google something like "CVPixelBuffer to UIImage/CGImage/etc."
if let capImg = self.arView.session.currentFrame?.capturedImage {
let ciimg = CIImage(cvPixelBuffer: capImg)
let myImage = UIImage(ciImage: ciimg)
// save image or whatever
}
Not accounting for rotation in my given example, there's examples of how to do that with a quick search.
I just tried a similar bit of code out with the same color settings, but didn't have any issues:
let tanchor = AnchorEntity(world: [0, -1, -1])
var simpMat = SimpleMaterial()
simpMat.baseColor = MaterialColorParameter.color(.init(red: 0.0, green: 1.0, blue: 1.0, alpha: 0.5))
let tcube = ModelEntity(
mesh: .generatePlane(width: 0.3, depth: 0.3),
materials: [simpMat]
)
tanchor.addChild(tcube)
self.arView.scene.addAnchor(tanchor)
(not anchored to a wall though in this example)
Maybe try using a cube with a very small height, or another shape and see if you get the same issue?
If you want an actual cylinder the .generateBox with cornerRadius method might not be the best option, as it will give you a capsule shape.
Seeing as RealityKit doesn’t let you generate a Cylinder normally I’ve had to be a little creative when doing this; the best method I’ve found, albeit dirty, is using generateText() - https://developer.apple.com/documentation/realitykit/meshresource/3244422-generatetext.
The steps are: Add mesh using .generateText(“.”) to a ModelEntity
use visualBounds - https://developer.apple.com/documentation/realitykit/modelentity/3244530-visualbounds method to check what dimensions it has given the cylinder
using the visual bounds .extents - https://developer.apple.com/documentation/realitykit/boundingbox/3243661-extents change the scale of the ModelEntity to match [1, 1, 1]
set the position of ModelEntity to negative .center - https://developer.apple.com/documentation/realitykit/boundingbox/3243656-center
make this ModelEntity the child of another Entity (just to simplify scale and rotations)
Then you’ll have a cylinder along the Z axis with dimensions the same as the Entity. However you cannot specify the number of segments or the level of detail using generateText(), like you can with SCNCylinder.
Thanks @BillyBag2, that works for me too!
I'll leave the FB request open, as passing in an otherwise valid font (even .systemFont) is broken, but this solves most of my issues 🙌
@Maci Yes it finally got through, I was basically displaying a small toast message, warning that using a VPN may interfere with MultipeerConnectivity interfaces when I noticed it was switched on, and then the reviewer approved. No confirmation that this was indeed the fix, but I can assume it was.
I left warning messages rather than just leaving a blanket stop because some site-access VPNs are okay, it's only specific site-to-site VPNs that divert all network communications, and I do not know how to tell the differences between them.
This is essentially the same as I use in my app. Although the keys could be slightly different, for example "tun0", "tun1" etc. So instead of exact matches my if statement looks like this:
if key.contains("tap") OR key.contains("tun") OR key.contains("ppp") OR key.contains("ipsec") {
return true
}
(replace OR with ||, seems that the code formatting on the forums likes to replace them with underscores?)
@maci I just added checks to see if VPN usage was detected and then the app was approved.
The reviewer never confirmed that turning it off is what fixed the issue or that he/she was even using a site-to-site VPN though.