@webspatial/platform-visionos 1.0.5 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/web-spatial/JSBCommand.swift +45 -53
- package/web-spatial/SpatialObject.swift +30 -14
- package/web-spatial/WebMsgCommand.swift +52 -50
- package/web-spatial/manager/Dynamic3DManager.swift +10 -12
- package/web-spatial/manager/FileCoordinator.swift +20 -0
- package/web-spatial/manager/WKWebViewManager.swift +9 -1
- package/web-spatial/manifest.swift +4 -1
- package/web-spatial/model/SpatialScene.swift +43 -13
- package/web-spatial/model/Spatialized2DElement.swift +2 -0
- package/web-spatial/model/SpatializedElement.swift +5 -6
- package/web-spatial/model/dynamic3d/SpatialEntity.swift +72 -69
- package/web-spatial/view/Spatialized2DElementView.swift +1 -1
- package/web-spatial/view/SpatializedDynamic3DView.swift +73 -64
- package/web-spatial/view/SpatializedElementView.swift +42 -46
- package/web-spatial/view/SpatializedStatic3DView.swift +2 -0
- package/web-spatial.xcodeproj/project.pbxproj +1 -0
- package/web-spatial.xcodeproj/xcshareddata/xcschemes/web-spatial.xcscheme +2 -2
package/package.json
CHANGED
|
@@ -17,17 +17,17 @@ struct CreateSpatializedStatic3DElement: CommandDataProtocol {
|
|
|
17
17
|
let modelURL: String
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
struct CreateSpatializedDynamic3DElement: CommandDataProtocol{
|
|
20
|
+
struct CreateSpatializedDynamic3DElement: CommandDataProtocol {
|
|
21
21
|
static let commandType: String = "CreateSpatializedDynamic3DElement"
|
|
22
22
|
let test: Bool
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
struct CreateSpatialEntity: CommandDataProtocol{
|
|
25
|
+
struct CreateSpatialEntity: CommandDataProtocol {
|
|
26
26
|
static let commandType: String = "CreateSpatialEntity"
|
|
27
27
|
let name: String?
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
struct CreateGeometryProperties: CommandDataProtocol{
|
|
30
|
+
struct CreateGeometryProperties: CommandDataProtocol {
|
|
31
31
|
static let commandType: String = "CreateGeometry"
|
|
32
32
|
let type: String
|
|
33
33
|
let width: Float?
|
|
@@ -38,7 +38,7 @@ struct CreateGeometryProperties: CommandDataProtocol{
|
|
|
38
38
|
let radius: Float?
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
struct CreateUnlitMaterial: CommandDataProtocol{
|
|
41
|
+
struct CreateUnlitMaterial: CommandDataProtocol {
|
|
42
42
|
static let commandType: String = "CreateUnlitMaterial"
|
|
43
43
|
let color: String?
|
|
44
44
|
let textureId: String?
|
|
@@ -46,87 +46,87 @@ struct CreateUnlitMaterial: CommandDataProtocol{
|
|
|
46
46
|
let opacity: Float?
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
struct CreateTexture: CommandDataProtocol{
|
|
49
|
+
struct CreateTexture: CommandDataProtocol {
|
|
50
50
|
static let commandType: String = "CreateTexture"
|
|
51
51
|
let url: String
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
struct CreateModelAsset: CommandDataProtocol{
|
|
54
|
+
struct CreateModelAsset: CommandDataProtocol {
|
|
55
55
|
static let commandType: String = "CreateModelAsset"
|
|
56
56
|
let url: String
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
struct CreateSpatialModelEntity: CommandDataProtocol{
|
|
59
|
+
struct CreateSpatialModelEntity: CommandDataProtocol {
|
|
60
60
|
static let commandType: String = "CreateSpatialModelEntity"
|
|
61
|
-
let modelAssetId:String
|
|
62
|
-
let name:String?
|
|
61
|
+
let modelAssetId: String
|
|
62
|
+
let name: String?
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
struct CreateModelComponent: CommandDataProtocol{
|
|
65
|
+
struct CreateModelComponent: CommandDataProtocol {
|
|
66
66
|
static let commandType: String = "CreateModelComponent"
|
|
67
67
|
let geometryId: String
|
|
68
68
|
let materialIds: [String]
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
struct AddComponentToEntity: CommandDataProtocol{
|
|
71
|
+
struct AddComponentToEntity: CommandDataProtocol {
|
|
72
72
|
static let commandType: String = "AddComponentToEntity"
|
|
73
73
|
let entityId: String
|
|
74
74
|
let componentId: String
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
struct AddEntityToDynamic3D: CommandDataProtocol{
|
|
77
|
+
struct AddEntityToDynamic3D: CommandDataProtocol {
|
|
78
78
|
static let commandType: String = "AddEntityToDynamic3D"
|
|
79
79
|
let dynamic3dId: String
|
|
80
80
|
let entityId: String
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
struct AddEntityToEntity: CommandDataProtocol{
|
|
83
|
+
struct AddEntityToEntity: CommandDataProtocol {
|
|
84
84
|
static let commandType: String = "AddEntityToEntity"
|
|
85
85
|
let childId: String
|
|
86
86
|
let parentId: String
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
struct SetParentForEntity: CommandDataProtocol{
|
|
89
|
+
struct SetParentForEntity: CommandDataProtocol {
|
|
90
90
|
static let commandType: String = "SetParentToEntity"
|
|
91
91
|
let childId: String
|
|
92
92
|
let parentId: String?
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
struct RemoveEntityFromParent: CommandDataProtocol{
|
|
95
|
+
struct RemoveEntityFromParent: CommandDataProtocol {
|
|
96
96
|
static let commandType: String = "RemoveEntityFromParent"
|
|
97
97
|
let entityId: String
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
struct UpdateEntityProperties: CommandDataProtocol{
|
|
100
|
+
struct UpdateEntityProperties: CommandDataProtocol {
|
|
101
101
|
static let commandType: String = "UpdateEntityProperties"
|
|
102
102
|
let entityId: String
|
|
103
|
-
let transform: [String:Float]
|
|
103
|
+
let transform: [String: Float]
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
struct UpdateEntityEvent: CommandDataProtocol{
|
|
106
|
+
struct UpdateEntityEvent: CommandDataProtocol {
|
|
107
107
|
static let commandType: String = "UpdateEntityEvent"
|
|
108
108
|
let type: String
|
|
109
109
|
let entityId: String
|
|
110
|
-
let isEnable:Bool
|
|
110
|
+
let isEnable: Bool
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
struct ConvertFromEntityToEntity: CommandDataProtocol{
|
|
113
|
+
struct ConvertFromEntityToEntity: CommandDataProtocol {
|
|
114
114
|
static let commandType: String = "ConvertFromEntityToEntity"
|
|
115
115
|
let fromEntityId: String
|
|
116
116
|
let toEntityId: String
|
|
117
|
-
let position:Vec3
|
|
117
|
+
let position: Vec3
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
struct ConvertFromEntityToScene: CommandDataProtocol{
|
|
120
|
+
struct ConvertFromEntityToScene: CommandDataProtocol {
|
|
121
121
|
static let commandType: String = "ConvertFromEntityToScene"
|
|
122
122
|
let fromEntityId: String
|
|
123
|
-
let position:Vec3
|
|
123
|
+
let position: Vec3
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
struct ConvertFromSceneToEntity: CommandDataProtocol{
|
|
126
|
+
struct ConvertFromSceneToEntity: CommandDataProtocol {
|
|
127
127
|
static let commandType: String = "ConvertFromSceneToEntity"
|
|
128
128
|
let entityId: String
|
|
129
|
-
let position:Vec3
|
|
129
|
+
let position: Vec3
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
struct InspectCommand: CommandDataProtocol {
|
|
@@ -156,15 +156,13 @@ protocol SpatializedElementProperties: SpatialObjectCommand {
|
|
|
156
156
|
var visible: Bool? { get }
|
|
157
157
|
var scrollWithParent: Bool? { get }
|
|
158
158
|
var zIndex: Double? { get }
|
|
159
|
-
|
|
159
|
+
|
|
160
160
|
var enableDragStartGesture: Bool? { get }
|
|
161
161
|
var enableDragGesture: Bool? { get }
|
|
162
162
|
var enableDragEndGesture: Bool? { get }
|
|
163
|
-
|
|
164
|
-
var enableRotateStartGesture: Bool? { get }
|
|
163
|
+
|
|
165
164
|
var enableRotateGesture: Bool? { get }
|
|
166
165
|
var enableRotateEndGesture: Bool? { get }
|
|
167
|
-
var enableMagnifyStartGesture: Bool? { get }
|
|
168
166
|
var enableMagnifyGesture: Bool? { get }
|
|
169
167
|
var enableMagnifyEndGesture: Bool? { get }
|
|
170
168
|
var enableTapGesture: Bool? { get }
|
|
@@ -185,22 +183,20 @@ struct UpdateSpatialized2DElementProperties: SpatializedElementProperties {
|
|
|
185
183
|
let visible: Bool?
|
|
186
184
|
let scrollWithParent: Bool?
|
|
187
185
|
let zIndex: Double?
|
|
188
|
-
|
|
186
|
+
|
|
189
187
|
var enableDragStartGesture: Bool?
|
|
190
188
|
var enableDragGesture: Bool?
|
|
191
189
|
var enableDragEndGesture: Bool?
|
|
192
|
-
var enableRotateStartGesture: Bool?
|
|
193
190
|
var enableRotateGesture: Bool?
|
|
194
191
|
var enableRotateEndGesture: Bool?
|
|
195
|
-
var enableMagnifyStartGesture: Bool?
|
|
196
192
|
var enableMagnifyGesture: Bool?
|
|
197
193
|
var enableMagnifyEndGesture: Bool?
|
|
198
|
-
var enableTapGesture: Bool?
|
|
199
|
-
|
|
194
|
+
var enableTapGesture: Bool?
|
|
195
|
+
|
|
200
196
|
let scrollPageEnabled: Bool?
|
|
201
197
|
let material: BackgroundMaterial?
|
|
202
198
|
let cornerRadius: CornerRadius?
|
|
203
|
-
|
|
199
|
+
|
|
204
200
|
// this value is used by previous WebSpatial code, keep it here only for Compatibility consideration
|
|
205
201
|
// may delete it when we think it's not needed
|
|
206
202
|
let scrollEdgeInsetsMarginRight: Double?
|
|
@@ -211,7 +207,7 @@ struct UpdateSpatializedStatic3DElementProperties: SpatializedElementProperties
|
|
|
211
207
|
let id: String
|
|
212
208
|
let name: String?
|
|
213
209
|
var clientX: Double?
|
|
214
|
-
var clientY: Double?
|
|
210
|
+
var clientY: Double?
|
|
215
211
|
let width: Double?
|
|
216
212
|
let height: Double?
|
|
217
213
|
let depth: Double?
|
|
@@ -221,14 +217,12 @@ struct UpdateSpatializedStatic3DElementProperties: SpatializedElementProperties
|
|
|
221
217
|
let visible: Bool?
|
|
222
218
|
let scrollWithParent: Bool?
|
|
223
219
|
let zIndex: Double?
|
|
224
|
-
|
|
220
|
+
|
|
225
221
|
var enableDragStartGesture: Bool?
|
|
226
222
|
let enableDragGesture: Bool?
|
|
227
223
|
let enableDragEndGesture: Bool?
|
|
228
|
-
var enableRotateStartGesture: Bool?
|
|
229
224
|
let enableRotateGesture: Bool?
|
|
230
225
|
let enableRotateEndGesture: Bool?
|
|
231
|
-
var enableMagnifyStartGesture: Bool?
|
|
232
226
|
let enableMagnifyGesture: Bool?
|
|
233
227
|
let enableMagnifyEndGesture: Bool?
|
|
234
228
|
let enableTapGesture: Bool?
|
|
@@ -252,14 +246,12 @@ struct UpdateSpatializedDynamic3DElementProperties: SpatializedElementProperties
|
|
|
252
246
|
let visible: Bool?
|
|
253
247
|
let scrollWithParent: Bool?
|
|
254
248
|
let zIndex: Double?
|
|
255
|
-
|
|
249
|
+
|
|
256
250
|
var enableDragStartGesture: Bool?
|
|
257
251
|
let enableDragGesture: Bool?
|
|
258
252
|
let enableDragEndGesture: Bool?
|
|
259
|
-
var enableRotateStartGesture: Bool?
|
|
260
253
|
let enableRotateGesture: Bool?
|
|
261
254
|
let enableRotateEndGesture: Bool?
|
|
262
|
-
var enableMagnifyStartGesture: Bool?
|
|
263
255
|
let enableMagnifyGesture: Bool?
|
|
264
256
|
let enableMagnifyEndGesture: Bool?
|
|
265
257
|
let enableTapGesture: Bool?
|
|
@@ -291,12 +283,12 @@ enum BaseplateVisibilityJSB: String, Codable {
|
|
|
291
283
|
case automatic
|
|
292
284
|
case visible
|
|
293
285
|
case hidden
|
|
294
|
-
|
|
286
|
+
|
|
295
287
|
var toSDK: Visibility {
|
|
296
288
|
switch self {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
289
|
+
case .automatic: return .automatic
|
|
290
|
+
case .visible: return .visible
|
|
291
|
+
case .hidden: return .hidden
|
|
300
292
|
}
|
|
301
293
|
}
|
|
302
294
|
}
|
|
@@ -304,11 +296,11 @@ enum BaseplateVisibilityJSB: String, Codable {
|
|
|
304
296
|
enum WorldScalingJSB: String, Codable {
|
|
305
297
|
case automatic
|
|
306
298
|
case dynamic
|
|
307
|
-
|
|
299
|
+
|
|
308
300
|
var toSDK: WorldScalingBehavior {
|
|
309
301
|
switch self {
|
|
310
|
-
|
|
311
|
-
|
|
302
|
+
case .automatic: return .automatic
|
|
303
|
+
case .dynamic: return .dynamic
|
|
312
304
|
}
|
|
313
305
|
}
|
|
314
306
|
}
|
|
@@ -317,12 +309,12 @@ enum WorldAlignmentJSB: String, Codable {
|
|
|
317
309
|
case adaptive
|
|
318
310
|
case automatic
|
|
319
311
|
case gravityAligned
|
|
320
|
-
|
|
312
|
+
|
|
321
313
|
var toSDK: WorldAlignmentBehavior {
|
|
322
314
|
switch self {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
315
|
+
case .adaptive: return .adaptive
|
|
316
|
+
case .automatic: return .automatic
|
|
317
|
+
case .gravityAligned: return .gravityAligned
|
|
326
318
|
}
|
|
327
319
|
}
|
|
328
320
|
}
|
|
@@ -15,26 +15,36 @@ class WeakReference<T: AnyObject> {
|
|
|
15
15
|
|
|
16
16
|
class SpatialObjectWeakRefManager {
|
|
17
17
|
static var weakRefObjects = [String: WeakReference<AnyObject>]()
|
|
18
|
-
|
|
18
|
+
private static let serialQueue = DispatchQueue(label: "com.xrsdk.spatialObjectWeakRefQueue")
|
|
19
|
+
|
|
19
20
|
static func setWeakRef<T: AnyObject>(_ id: String, _ object: T) {
|
|
20
|
-
|
|
21
|
+
serialQueue.sync {
|
|
22
|
+
weakRefObjects[id] = WeakReference(object as AnyObject)
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
|
-
|
|
25
|
+
|
|
23
26
|
static func getWeakRef(_ id: String) -> AnyObject? {
|
|
24
|
-
|
|
27
|
+
serialQueue.sync {
|
|
28
|
+
weakRefObjects[id]?.value
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
|
-
|
|
31
|
+
|
|
27
32
|
static func removeWeakRef(_ id: String) {
|
|
28
|
-
|
|
33
|
+
serialQueue.sync {
|
|
34
|
+
weakRefObjects.removeValue(forKey: id)
|
|
35
|
+
}
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
class SpatialObject: SpatialObjectProtocol {
|
|
33
|
-
|
|
34
|
-
static var objects = [String:
|
|
35
|
-
|
|
40
|
+
var listeners: [String: [(Any, Any) -> Void]] = [:]
|
|
41
|
+
static var objects = [String: any SpatialObjectProtocol]()
|
|
42
|
+
static let serialQueue = DispatchQueue(label: "com.xrsdk.spatialObjectQueue")
|
|
43
|
+
|
|
36
44
|
static func get(_ id: String) -> (any SpatialObjectProtocol)? {
|
|
37
|
-
|
|
45
|
+
serialQueue.sync {
|
|
46
|
+
objects[id]
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
static func getRefObject(_ id: String) -> SpatialObject? {
|
|
@@ -69,14 +79,18 @@ class SpatialObject: SpatialObjectProtocol {
|
|
|
69
79
|
init() {
|
|
70
80
|
spatialId = UUID().uuidString
|
|
71
81
|
id = spatialId
|
|
72
|
-
SpatialObject.
|
|
82
|
+
SpatialObject.serialQueue.sync {
|
|
83
|
+
SpatialObject.objects[spatialId] = self
|
|
84
|
+
}
|
|
73
85
|
SpatialObjectWeakRefManager.setWeakRef(spatialId, self)
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
init(_ _id: String) {
|
|
77
89
|
spatialId = _id
|
|
78
90
|
id = spatialId
|
|
79
|
-
SpatialObject.
|
|
91
|
+
SpatialObject.serialQueue.sync {
|
|
92
|
+
SpatialObject.objects[spatialId] = self
|
|
93
|
+
}
|
|
80
94
|
SpatialObjectWeakRefManager.setWeakRef(spatialId, self)
|
|
81
95
|
}
|
|
82
96
|
|
|
@@ -99,10 +113,12 @@ class SpatialObject: SpatialObjectProtocol {
|
|
|
99
113
|
_isDestroyed = true
|
|
100
114
|
|
|
101
115
|
emit(event: Events.Destroyed.rawValue, data: ["object": self])
|
|
102
|
-
SpatialObject.
|
|
116
|
+
SpatialObject.serialQueue.sync {
|
|
117
|
+
SpatialObject.objects.removeValue(forKey: spatialId)
|
|
118
|
+
}
|
|
103
119
|
|
|
104
120
|
listeners = [:]
|
|
105
121
|
}
|
|
106
122
|
|
|
107
|
-
|
|
123
|
+
func onDestroy() {}
|
|
108
124
|
}
|
|
@@ -3,44 +3,43 @@
|
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
5
|
enum WebSpatialGestureType: String, Encodable {
|
|
6
|
-
case spatialtap
|
|
7
|
-
case spatialdragstart
|
|
8
|
-
case spatialdrag
|
|
9
|
-
case spatialdragend
|
|
10
|
-
case
|
|
11
|
-
case
|
|
12
|
-
case
|
|
13
|
-
case
|
|
14
|
-
case spatialmagnify = "spatialmagnify"
|
|
15
|
-
case spatialmagnifyend = "spatialmagnifyend"
|
|
6
|
+
case spatialtap
|
|
7
|
+
case spatialdragstart
|
|
8
|
+
case spatialdrag
|
|
9
|
+
case spatialdragend
|
|
10
|
+
case spatialrotate
|
|
11
|
+
case spatialrotateend
|
|
12
|
+
case spatialmagnify
|
|
13
|
+
case spatialmagnifyend
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
enum SpatialWebMsgType: String, Encodable {
|
|
19
|
-
case cubeInfo
|
|
20
|
-
case transform
|
|
21
|
-
case modelloaded
|
|
22
|
-
case modelloadfailed
|
|
23
|
-
case spatialtap
|
|
24
|
-
case
|
|
25
|
-
case
|
|
26
|
-
case
|
|
27
|
-
case
|
|
28
|
-
case
|
|
29
|
-
case
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
case cubeInfo
|
|
18
|
+
case transform
|
|
19
|
+
case modelloaded
|
|
20
|
+
case modelloadfailed
|
|
21
|
+
case spatialtap
|
|
22
|
+
case spatialdragstart
|
|
23
|
+
case spatialdrag
|
|
24
|
+
case spatialdragend
|
|
25
|
+
case spatialrotate
|
|
26
|
+
case spatialrotateend
|
|
27
|
+
case spatialmagnify
|
|
28
|
+
case spatialmagnifyend
|
|
29
|
+
|
|
30
|
+
case objectdestroy
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
// notify Spatialized3DElement Container Cube, used for ref.current.getBoundingClientCube()
|
|
35
34
|
struct SpatiaizedContainerClientCube: Encodable {
|
|
36
|
-
let type: SpatialWebMsgType =
|
|
35
|
+
let type: SpatialWebMsgType = .cubeInfo
|
|
37
36
|
let origin: Point3D
|
|
38
37
|
let size: Size3D
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
// notify Spatialized3DElement Container Transform to SpatialScene, used for ref.current.convertToSpatialScene()
|
|
42
41
|
struct SpatiaizedContainerTransform: Encodable {
|
|
43
|
-
let type: SpatialWebMsgType =
|
|
42
|
+
let type: SpatialWebMsgType = .transform
|
|
44
43
|
let detail: AffineTransform3D
|
|
45
44
|
}
|
|
46
45
|
|
|
@@ -50,70 +49,73 @@ struct WebSpatialTapGuestureEventDetail: Encodable {
|
|
|
50
49
|
|
|
51
50
|
// notify SpatializedElement/SpatialEntity tapped
|
|
52
51
|
struct WebSpatialTapGuestureEvent: Encodable {
|
|
53
|
-
let type: SpatialWebMsgType =
|
|
52
|
+
let type: SpatialWebMsgType = .spatialtap
|
|
54
53
|
let detail: WebSpatialTapGuestureEventDetail
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
struct
|
|
58
|
-
let location3D: Point3D
|
|
56
|
+
struct WebSpatialDragStartGuestureEventDetail: Encodable {
|
|
59
57
|
let startLocation3D: Point3D
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
struct WebSpatialDragStartGuestureEvent: Encodable {
|
|
61
|
+
let type: SpatialWebMsgType = .spatialdragstart
|
|
62
|
+
let detail: WebSpatialDragStartGuestureEventDetail
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
struct WebSpatialDragGuestureEventDetail: Encodable {
|
|
60
66
|
let translation3D: Vector3D
|
|
61
|
-
let predictedEndTranslation3D: Vector3D
|
|
62
|
-
let predictedEndLocation3D: Point3D
|
|
63
|
-
let velocity: CGSize
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
struct WebSpatialDragGuestureEvent: Encodable {
|
|
67
|
-
let type: SpatialWebMsgType =
|
|
70
|
+
let type: SpatialWebMsgType = .spatialdrag
|
|
68
71
|
let detail: WebSpatialDragGuestureEventDetail
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
struct WebSpatialDragEndGuestureEvent: Encodable {
|
|
72
|
-
let type: SpatialWebMsgType =
|
|
73
|
-
|
|
75
|
+
let type: SpatialWebMsgType = .spatialdragend
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
struct Quaternion: Encodable {
|
|
79
|
+
let x: Double
|
|
80
|
+
let y: Double
|
|
81
|
+
let z: Double
|
|
82
|
+
let w: Double
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
struct WebSpatialRotateGuestureEventDetail: Encodable {
|
|
77
|
-
let
|
|
78
|
-
let startAnchor3D: UnitPoint3D
|
|
79
|
-
let startLocation3D: Point3D
|
|
80
|
-
|
|
86
|
+
let quaternion: Quaternion
|
|
81
87
|
}
|
|
88
|
+
|
|
82
89
|
struct WebSpatialRotateGuestureEvent: Encodable {
|
|
83
|
-
let type: SpatialWebMsgType =
|
|
90
|
+
let type: SpatialWebMsgType = .spatialrotate
|
|
84
91
|
let detail: WebSpatialRotateGuestureEventDetail
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
struct WebSpatialRotateEndGuestureEvent: Encodable {
|
|
88
|
-
let type: SpatialWebMsgType =
|
|
89
|
-
let detail: WebSpatialRotateGuestureEventDetail
|
|
95
|
+
let type: SpatialWebMsgType = .spatialrotateend
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
struct WebSpatialMagnifyGuestureEventDetail: Encodable {
|
|
93
99
|
let magnification: CGFloat
|
|
94
|
-
let velocity: CGFloat
|
|
95
|
-
let startLocation3D: Point3D
|
|
96
|
-
let startAnchor3D: UnitPoint3D
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
struct WebSpatialMagnifyGuestureEvent: Encodable {
|
|
100
|
-
let type: SpatialWebMsgType =
|
|
103
|
+
let type: SpatialWebMsgType = .spatialmagnify
|
|
101
104
|
let detail: WebSpatialMagnifyGuestureEventDetail
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
struct WebSpatialMagnifyEndGuestureEvent: Encodable {
|
|
105
|
-
let type: SpatialWebMsgType =
|
|
106
|
-
let detail: WebSpatialMagnifyGuestureEventDetail
|
|
108
|
+
let type: SpatialWebMsgType = .spatialmagnifyend
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
struct ModelLoadSuccess: Encodable {
|
|
110
|
-
let type: SpatialWebMsgType =
|
|
112
|
+
let type: SpatialWebMsgType = .modelloaded
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
struct ModelLoadFailure: Encodable {
|
|
114
|
-
let type: SpatialWebMsgType =
|
|
116
|
+
let type: SpatialWebMsgType = .modelloadfailed
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
struct SpatialObjectDestroiedEvent: Encodable {
|
|
118
|
-
let type: SpatialWebMsgType =
|
|
120
|
+
let type: SpatialWebMsgType = .objectdestroy
|
|
119
121
|
}
|
|
@@ -75,8 +75,8 @@ class Dynamic3DManager {
|
|
|
75
75
|
loadComplete(.failure(NSError(domain: "Invalid URL", code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to create URL from string: \(urlString)"])))
|
|
76
76
|
return
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
documentsUrl.
|
|
78
|
+
// Use an immutable URL to avoid capturing a mutable var in concurrent code
|
|
79
|
+
let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent(url.lastPathComponent)
|
|
80
80
|
let session = URLSession(configuration: URLSessionConfiguration.default)
|
|
81
81
|
var request = URLRequest(url: url)
|
|
82
82
|
request.httpMethod = "GET"
|
|
@@ -95,17 +95,15 @@ class Dynamic3DManager {
|
|
|
95
95
|
loadComplete(.failure(NSError(domain: "Download Error", code: 0, userInfo: [NSLocalizedDescriptionKey: "Download location is nil"])))
|
|
96
96
|
return
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
Task {
|
|
99
|
+
do {
|
|
100
|
+
try await FileCoordinator.shared.moveReplacingIfExists(from: location, to: documentsUrl)
|
|
101
|
+
print("load complete")
|
|
102
|
+
loadComplete(.success(documentsUrl))
|
|
103
|
+
} catch {
|
|
104
|
+
print("File operation error: \(error)")
|
|
105
|
+
loadComplete(.failure(error))
|
|
102
106
|
}
|
|
103
|
-
try fileManager.moveItem(at: location, to: documentsUrl)
|
|
104
|
-
print("load complete")
|
|
105
|
-
loadComplete(.success(documentsUrl))
|
|
106
|
-
} catch {
|
|
107
|
-
print("File operation error: \(error)")
|
|
108
|
-
loadComplete(.failure(error))
|
|
109
107
|
}
|
|
110
108
|
|
|
111
109
|
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
actor FileCoordinator {
|
|
4
|
+
static let shared = FileCoordinator()
|
|
5
|
+
|
|
6
|
+
func moveReplacingIfExists(from sourceURL: URL, to destinationURL: URL) throws {
|
|
7
|
+
let fm = FileManager.default
|
|
8
|
+
if fm.fileExists(atPath: destinationURL.path) {
|
|
9
|
+
try fm.removeItem(at: destinationURL)
|
|
10
|
+
}
|
|
11
|
+
try fm.moveItem(at: sourceURL, to: destinationURL)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
func removeIfExists(at url: URL) throws {
|
|
15
|
+
let fm = FileManager.default
|
|
16
|
+
if fm.fileExists(atPath: url.path) {
|
|
17
|
+
try fm.removeItem(at: url)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -28,11 +28,19 @@ class WKWebViewManager {
|
|
|
28
28
|
// TODO: get native api instead of PACKAGE_VERSION
|
|
29
29
|
controller.webview!.customUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7; wv) AppleWebKit\(webviewVersion)WebSpatial/\("PACKAGE_VERSION") SpatialID/\(spatialId!)"
|
|
30
30
|
controller.webview!.uiDelegate = controller
|
|
31
|
-
controller.webview!.allowsBackForwardNavigationGestures =
|
|
31
|
+
controller.webview!.allowsBackForwardNavigationGestures = false
|
|
32
32
|
controller.webview!.isInspectable = true
|
|
33
33
|
controller.webview!.allowsLinkPreview = true
|
|
34
34
|
controller.webview!.navigationDelegate = controller
|
|
35
35
|
controller.webview!.scrollView.delegate = controller
|
|
36
|
+
|
|
37
|
+
if let webview = controller.webview {
|
|
38
|
+
// webview.scrollView.isScrollEnabled = false
|
|
39
|
+
webview.scrollView.bounces = false
|
|
40
|
+
webview.scrollView.showsVerticalScrollIndicator = false
|
|
41
|
+
webview.scrollView.showsHorizontalScrollIndicator = false
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
controller.startObserving()
|
|
37
45
|
return controller.webview!
|
|
38
46
|
}
|
|
@@ -5,7 +5,10 @@ var pwaManager = PWAManager()
|
|
|
5
5
|
|
|
6
6
|
struct PWAManager: Codable {
|
|
7
7
|
var isLocal: Bool = false
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
var start_url: String = "http://localhost:5173"
|
|
10
|
+
|
|
11
|
+
// var start_url: String = "http://localhost:5173/webspatial/avp/materialApiTest"
|
|
9
12
|
|
|
10
13
|
var scope: String = ""
|
|
11
14
|
var id: String = "com.webspatial.pico"
|