-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
SCNBoxExtensions.swift
83 lines (74 loc) · 4.05 KB
/
SCNBoxExtensions.swift
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// SCNBoxExtensions.swift - Copyright 2024 SwifterSwift
#if canImport(SceneKit)
import SceneKit
// MARK: - Methods
public extension SCNBox {
/// SwifterSwift: Creates a box geometry with the specified width, height, and length.
///
/// - Parameters:
/// - width: The width of the box along the x-axis of its local coordinate space.
/// - height: The height of the box along the y-axis of its local coordinate space.
/// - length: The length of the box along the z-axis of its local coordinate space.
convenience init(width: CGFloat, height: CGFloat, length: CGFloat) {
self.init(width: width, height: height, length: length, chamferRadius: 0)
}
/// SwifterSwift: Creates a cube geometry with the specified side length, and chamfer radius.
///
/// - Parameters:
/// - sideLength: The width, height, and length of the box in its local coordinate space.
/// - chamferRadius: The radius of curvature for the edges and corners of the box.
convenience init(sideLength: CGFloat, chamferRadius: CGFloat = 0) {
self.init(width: sideLength, height: sideLength, length: sideLength, chamferRadius: chamferRadius)
}
/// SwifterSwift: Creates a box geometry with the specified width, height, length, chamfer radius, and material.
///
/// - Parameters:
/// - width: The width of the box along the x-axis of its local coordinate space.
/// - height: The height of the box along the y-axis of its local coordinate space.
/// - length: The length of the box along the z-axis of its local coordinate space.
/// - chamferRadius: The radius of curvature for the edges and corners of the box.
/// - material: The material of the geometry.
convenience init(
width: CGFloat,
height: CGFloat,
length: CGFloat,
chamferRadius: CGFloat = 0,
material: SCNMaterial) {
self.init(width: width, height: height, length: length, chamferRadius: chamferRadius)
materials = [material]
}
/// SwifterSwift: Creates a cube geometry with the specified side length, chamfer radius, and material.
///
/// - Parameters:
/// - sideLength: The width, height, and length of the box in its local coordinate space.
/// - chamferRadius: The radius of curvature for the edges and corners of the box.
/// - material: The material of the geometry.
convenience init(sideLength: CGFloat, chamferRadius: CGFloat = 0, material: SCNMaterial) {
self.init(width: sideLength, height: sideLength, length: sideLength, chamferRadius: chamferRadius)
materials = [material]
}
/// SwifterSwift: Creates a box geometry with the specified width, height, length, chamfer radius, and material
/// color.
///
/// - Parameters:
/// - width: The width of the box along the x-axis of its local coordinate space.
/// - height: The height of the box along the y-axis of its local coordinate space.
/// - length: The length of the box along the z-axis of its local coordinate space.
/// - chamferRadius: The radius of curvature for the edges and corners of the box.
/// - color: The color of the geometry's material.
convenience init(width: CGFloat, height: CGFloat, length: CGFloat, chamferRadius: CGFloat = 0, color: SFColor) {
self.init(width: width, height: height, length: length, chamferRadius: chamferRadius)
materials = [SCNMaterial(color: color)]
}
/// SwifterSwift: Creates a cube geometry with the specified side length, chamfer radius, and material color.
///
/// - Parameters:
/// - sideLength: The width, height, and length of the box in its local coordinate space.
/// - chamferRadius: The radius of curvature for the edges and corners of the box.
/// - color: The color of the geometry's material.
convenience init(sideLength: CGFloat, chamferRadius: CGFloat = 0, color: SFColor) {
self.init(width: sideLength, height: sideLength, length: sideLength, chamferRadius: chamferRadius)
materials = [SCNMaterial(color: color)]
}
}
#endif