@webspatial/platform-visionos 1.7.0 → 2.0.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 +1 -0
- package/web-spatial/WebMsgCommand.swift +26 -2
- package/web-spatial/WebSpatialApp.swift +26 -8
- package/web-spatial/manifest.swift +1 -1
- package/web-spatial/model/SpatialScene.swift +178 -39
- package/web-spatial/model/Spatialized2DElement.swift +2 -11
- package/web-spatial/model/SpatializedElement.swift +38 -0
- package/web-spatial/model/SpatializedStatic3DElement.swift +27 -8
- package/web-spatial/model/dynamic3d/EntityAnimationManager.swift +356 -0
- package/web-spatial/model/dynamic3d/EntityAnimationSession.swift +162 -0
- package/web-spatial/model/element-motion/SpatializedElementAnimationCommand.swift +15 -0
- package/web-spatial/model/element-motion/SpatializedElementAnimationManager.swift +263 -0
- package/web-spatial/model/element-motion/SpatializedElementAnimationObject.swift +399 -0
- package/web-spatial/model/element-motion/SpatializedElementAnimationTypes.swift +45 -0
- package/web-spatial/model/element-motion/SpatializedElementAnimationWriteAdapter.swift +65 -0
- package/web-spatial/model/element-motion/SpatializedElementMotionBridgeTypes.swift +43 -0
- package/web-spatial/model/element-motion/SpatializedElementMotionTimelineSampler.swift +99 -0
- package/web-spatial/model/element-motion/SpatializedElementMotionTiming.swift +99 -0
- package/web-spatial/model/element-motion/SpatializedElementMotionTransformTypes.swift +22 -0
- package/web-spatial/protocol/SpatializedElementContainer.swift +1 -1
- package/web-spatial/view/SpatialNavView.swift +37 -12
- package/web-spatial/view/SpatialSceneContentView.swift +9 -12
- package/web-spatial/view/Spatialized2DElementView.swift +10 -17
- package/web-spatial/view/SpatializedDynamic3DView.swift +2 -6
- package/web-spatial/view/SpatializedElementView.swift +3 -2
- package/web-spatial/view/SpatializedStatic3DView.swift +32 -33
- package/web-spatial/view/view-modifier/OrbitModifier.swift +84 -0
- package/web-spatial/webview/SpatialWebController.swift +26 -18
- package/web-spatial/webview/SpatialWebViewModel.swift +12 -7
- package/web-spatial.xcodeproj/project.pbxproj +29 -8
- package/web-spatial.xcodeproj/xcshareddata/xcschemes/web-spatial.xcscheme +1 -1
- package/web-spatialTests/NavigationCleanupTests.swift +2 -1
- package/web-spatialTests/SpatializedElementAnimationManagerTests.swift +1466 -0
- package/web-spatialTests/SpatializedElementMotionTimelineSamplerTests.swift +117 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
@testable import WebSpatial
|
|
2
|
+
import XCTest
|
|
3
|
+
|
|
4
|
+
final class SpatializedElementMotionTimelineSamplerTests: XCTestCase {
|
|
5
|
+
func test_canonicalMultiTrackSamplesMatchWebEvaluator() {
|
|
6
|
+
let timeline = SpatializedMotionTimelinePayload(
|
|
7
|
+
duration: 5,
|
|
8
|
+
delay: nil,
|
|
9
|
+
playbackRate: nil,
|
|
10
|
+
loop: nil,
|
|
11
|
+
tracks: [
|
|
12
|
+
SpatializedMotionTrackPayload(
|
|
13
|
+
property: "transform.translate.x",
|
|
14
|
+
keyframes: [
|
|
15
|
+
SpatializedMotionKeyframePayload(at: 0, value: 0, timingFunction: "linear"),
|
|
16
|
+
SpatializedMotionKeyframePayload(at: 5, value: 100, timingFunction: nil),
|
|
17
|
+
],
|
|
18
|
+
timingFunction: "linear"
|
|
19
|
+
),
|
|
20
|
+
SpatializedMotionTrackPayload(
|
|
21
|
+
property: "opacity",
|
|
22
|
+
keyframes: [
|
|
23
|
+
SpatializedMotionKeyframePayload(at: 3, value: 0, timingFunction: "easeOut"),
|
|
24
|
+
SpatializedMotionKeyframePayload(at: 5, value: 1, timingFunction: nil),
|
|
25
|
+
],
|
|
26
|
+
timingFunction: "linear"
|
|
27
|
+
),
|
|
28
|
+
]
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
let sampler = SpatializedElementMotionTimelineSampler(
|
|
32
|
+
timeline: timeline,
|
|
33
|
+
baselineTransform: .identity,
|
|
34
|
+
baselineOpacity: 1
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
let early = sampler.sampleTransformAndOpacity(at: 1.5)
|
|
38
|
+
XCTAssertEqual(early.transform.translateX, 30, accuracy: 0.5)
|
|
39
|
+
XCTAssertEqual(early.opacity, 0, accuracy: 0.01)
|
|
40
|
+
|
|
41
|
+
let final = sampler.sampleTransformAndOpacity(at: 5)
|
|
42
|
+
XCTAssertEqual(final.transform.translateX, 100, accuracy: 0.5)
|
|
43
|
+
XCTAssertEqual(final.opacity, 1, accuracy: 0.01)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
func test_translateZDepthTrackSamples() {
|
|
47
|
+
let timeline = SpatializedMotionTimelinePayload(
|
|
48
|
+
duration: 4,
|
|
49
|
+
delay: nil,
|
|
50
|
+
playbackRate: nil,
|
|
51
|
+
loop: nil,
|
|
52
|
+
tracks: [
|
|
53
|
+
SpatializedMotionTrackPayload(
|
|
54
|
+
property: "transform.translate.z",
|
|
55
|
+
keyframes: [
|
|
56
|
+
SpatializedMotionKeyframePayload(at: 0, value: 0, timingFunction: nil),
|
|
57
|
+
SpatializedMotionKeyframePayload(at: 4, value: -120, timingFunction: nil),
|
|
58
|
+
],
|
|
59
|
+
timingFunction: "linear"
|
|
60
|
+
),
|
|
61
|
+
]
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
let sampler = SpatializedElementMotionTimelineSampler(
|
|
65
|
+
timeline: timeline,
|
|
66
|
+
baselineTransform: .identity,
|
|
67
|
+
baselineOpacity: 1
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
let mid = sampler.sampleTransformAndOpacity(at: 2)
|
|
71
|
+
XCTAssertEqual(mid.transform.translateZ, -60, accuracy: 0.5)
|
|
72
|
+
|
|
73
|
+
let end = sampler.sampleTransformAndOpacity(at: 4)
|
|
74
|
+
XCTAssertEqual(end.transform.translateZ, -120, accuracy: 0.5)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
func test_rotateYAndRotateZTracksSample() {
|
|
78
|
+
let timeline = SpatializedMotionTimelinePayload(
|
|
79
|
+
duration: 4,
|
|
80
|
+
delay: nil,
|
|
81
|
+
playbackRate: nil,
|
|
82
|
+
loop: nil,
|
|
83
|
+
tracks: [
|
|
84
|
+
SpatializedMotionTrackPayload(
|
|
85
|
+
property: "transform.rotate.y",
|
|
86
|
+
keyframes: [
|
|
87
|
+
SpatializedMotionKeyframePayload(at: 0, value: 0, timingFunction: nil),
|
|
88
|
+
SpatializedMotionKeyframePayload(at: 4, value: 90, timingFunction: nil),
|
|
89
|
+
],
|
|
90
|
+
timingFunction: "linear"
|
|
91
|
+
),
|
|
92
|
+
SpatializedMotionTrackPayload(
|
|
93
|
+
property: "transform.rotate.z",
|
|
94
|
+
keyframes: [
|
|
95
|
+
SpatializedMotionKeyframePayload(at: 1, value: 0, timingFunction: nil),
|
|
96
|
+
SpatializedMotionKeyframePayload(at: 4, value: 180, timingFunction: nil),
|
|
97
|
+
],
|
|
98
|
+
timingFunction: "linear"
|
|
99
|
+
),
|
|
100
|
+
]
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
let sampler = SpatializedElementMotionTimelineSampler(
|
|
104
|
+
timeline: timeline,
|
|
105
|
+
baselineTransform: .identity,
|
|
106
|
+
baselineOpacity: 1
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
let t2 = sampler.sampleTransformAndOpacity(at: 2)
|
|
110
|
+
XCTAssertEqual(t2.transform.rotateY, 45, accuracy: 0.5)
|
|
111
|
+
XCTAssertEqual(t2.transform.rotateZ, 60, accuracy: 0.5)
|
|
112
|
+
|
|
113
|
+
let t3 = sampler.sampleTransformAndOpacity(at: 3)
|
|
114
|
+
XCTAssertEqual(t3.transform.rotateY, 67.5, accuracy: 0.5)
|
|
115
|
+
XCTAssertEqual(t3.transform.rotateZ, 120, accuracy: 0.5)
|
|
116
|
+
}
|
|
117
|
+
}
|