質問編集履歴
1
RealityKitでの画像の表示コードについて追記いたしました。ご確認よろしくお願いいたします
test
CHANGED
File without changes
|
test
CHANGED
@@ -143,36 +143,7 @@
|
|
143
143
|
return_y_angle = [0]
|
144
144
|
return_z_angle = [0]
|
145
145
|
|
146
|
-
|
147
|
-
print("Photo Ground Module")
|
148
|
-
case "Photo Air Module":
|
149
|
-
print("Photo Air Module")
|
150
|
-
case "Photo Dome Module":
|
151
|
-
return_x_list = [0,2.12,3,2.12,0,-2.12,-3,-2.12,0,2.12,3,2.12,0,-2.12,-3,-2.12,0,2.12,3,2.12,0,-2.12,-3,-2.12,0,2.12,3,2.12,0,-2.12,-3,-2.12,]
|
152
|
-
return_y_list = [-1,-1,-1,-1,-1,-1,-1,-1,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,4,4,4,4,4,4,4,4,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5]
|
153
|
-
|
154
|
-
return_z_list = [3,2.12,0,-2.12,-3,-2.12,0,2.12,3,2.12,0,-2.12,-3,-2.12,0,2.12,3,2.12,0,-2.12,-3,-2.12,0,2.12,3,2.12,0,-2.12,-3,-2.12,0,2.12,]
|
155
|
-
return_scale = [2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0]
|
156
|
-
return_x_angle = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.pi/10,0,0,0,-.pi/10,0,0,0,0,0,0,0,0,0,0,0]
|
157
|
-
|
158
|
-
return_y_angle = [0,70,80,-70,0,70,-80,0,0,70,80,-70,0,70,-80,0,0,70,80,-70,0,70,-80,0,0,70,80,-70,0,70,-80,0]
|
159
|
-
return_z_angle = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-.pi/10,0,0,0,.pi/10,0,0,0,0,0,0,0,0,0]
|
160
|
-
case "Photo Load Module":
|
161
|
-
return_x_list = [-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,]
|
162
|
-
return_y_list = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
163
|
-
return_z_list = [-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17,-18,-19,-20,-21,-22,-23,-24,-25,-26,-27,-28,-29,-30]
|
164
|
-
return_scale = [2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0]
|
165
|
-
return_x_angle = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
166
|
-
return_y_angle = [.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,.pi/3,-.pi/3,]
|
167
|
-
return_z_angle = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
168
|
-
case "Photo Backscreen Message Module":
|
169
|
-
print("Photo Backscreen Message Module")
|
170
|
-
case "Photo Ground Message Module":
|
171
|
-
print("Photo Ground Message Module")
|
172
|
-
case "Photo Air Message Module":
|
173
|
-
print("Photo Air Message Module")
|
174
|
-
case "Photo Dome Message Module":
|
175
|
-
print("Photo Dome Message Module")
|
146
|
+
|
176
147
|
case "Photo Load Message Module":
|
177
148
|
return_x_list = [-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,-3,3,]
|
178
149
|
return_y_list = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
@@ -192,3 +163,88 @@
|
|
192
163
|
}
|
193
164
|
|
194
165
|
```
|
166
|
+
|
167
|
+
```swift
|
168
|
+
|
169
|
+
import UIKit
|
170
|
+
import RealityKit
|
171
|
+
import ARKit
|
172
|
+
|
173
|
+
class ViewController: UIViewController,ARSessionDelegate {
|
174
|
+
|
175
|
+
@IBOutlet var arView: ARView!
|
176
|
+
var anchor = AnchorEntity()
|
177
|
+
|
178
|
+
|
179
|
+
override func viewDidLoad() {
|
180
|
+
super.viewDidLoad()
|
181
|
+
|
182
|
+
// デリゲートを設定
|
183
|
+
arView.session.delegate = self
|
184
|
+
|
185
|
+
|
186
|
+
}
|
187
|
+
|
188
|
+
|
189
|
+
override func viewDidAppear(_ animated: Bool) {
|
190
|
+
super.viewDidAppear(animated)
|
191
|
+
|
192
|
+
resetTracking()
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
// ARセッションをリセットする
|
197
|
+
func resetTracking() {
|
198
|
+
// ビューのシーン認識オプションを設定する
|
199
|
+
arView.environment.sceneUnderstanding.options = [.occlusion,
|
200
|
+
.physics,
|
201
|
+
.receivesLighting]
|
202
|
+
let config = ARWorldTrackingConfiguration()
|
203
|
+
// シーン再構築を有効化する
|
204
|
+
if ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh) {
|
205
|
+
config.sceneReconstruction = .mesh
|
206
|
+
}
|
207
|
+
|
208
|
+
// 水平面を検出する
|
209
|
+
config.planeDetection = [.horizontal]
|
210
|
+
|
211
|
+
// 環境テクスチャーマッピングを有効化する
|
212
|
+
config.environmentTexturing = .automatic
|
213
|
+
|
214
|
+
// 人物によるオクルージョンを行う
|
215
|
+
if ARWorldTrackingConfiguration.supportsFrameSemantics(
|
216
|
+
.personSegmentationWithDepth) {
|
217
|
+
config.frameSemantics.insert(.personSegmentationWithDepth)
|
218
|
+
}
|
219
|
+
|
220
|
+
self.anchor = AnchorEntity(world: [0,0,-2])
|
221
|
+
|
222
|
+
let ball: MeshResource = .generateSphere(radius: 0.25)
|
223
|
+
|
224
|
+
var material = UnlitMaterial()
|
225
|
+
|
226
|
+
if #available(iOS 15.0, *) {
|
227
|
+
let image = UIImage(named: "pictures")
|
228
|
+
|
229
|
+
material.color = try! .init(tint: .white,
|
230
|
+
texture: .init(.load(named: "pictures",
|
231
|
+
in: nil)))
|
232
|
+
}
|
233
|
+
|
234
|
+
let ballEntity = ModelEntity(mesh: .generatePlane(width: 2, height: 1.5), materials: [material])
|
235
|
+
|
236
|
+
self.anchor.addChild(ballEntity)
|
237
|
+
|
238
|
+
self.arView.scene.anchors.append(self.anchor)
|
239
|
+
// セッションを開始する
|
240
|
+
arView.session.run(config, options: [.removeExistingAnchors, .resetTracking])
|
241
|
+
|
242
|
+
}
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
```
|