universo-platform-3d

Форк
0
222 строки · 3.8 Кб
1
import { ApiProperty } from '@nestjs/swagger'
2
import {
3
  IsArray,
4
  IsBoolean,
5
  IsMongoId,
6
  IsNotEmpty,
7
  IsNumber,
8
  IsOptional,
9
  IsString,
10
  MaxLength,
11
  MinLength
12
} from 'class-validator'
13
import { Vector3AsArray, Vector4AsArray } from '../../option-sets/vectors'
14
import { AssetId } from '../../util/mongo-object-id-helpers'
15

16
export class CreateSpaceObjectDto {
17
  /**
18
   * Required properties
19
   */
20
  @IsNotEmpty()
21
  @IsString()
22
  @MinLength(24, {
23
    message: 'A Mongo ObjectId is 24 characters'
24
  })
25
  @MaxLength(24, {
26
    message: 'A Mongo ObjectId is 24 characters'
27
  })
28
  @ApiProperty({
29
    required: true
30
  })
31
  spaceId: string
32

33
  @IsNotEmpty()
34
  @IsString()
35
  @MaxLength(300) // abitrary max length
36
  @ApiProperty({
37
    example: 'A Cool Space Object'
38
  })
39
  name: string
40

41
  @IsNotEmpty()
42
  @IsMongoId()
43
  @ApiProperty()
44
  asset: AssetId // TODO make this clear that it's an assetId
45

46
  /**
47
   * Optional properties
48
   */
49
  @IsOptional()
50
  @IsString()
51
  @ApiProperty()
52
  parentSpaceObject?: string
53

54
  @IsOptional()
55
  @IsString()
56
  @ApiProperty({
57
    example: "A Cool Space Object's Description"
58
  })
59
  description?: string
60

61
  @IsOptional()
62
  @ApiProperty()
63
  locked?: boolean
64

65
  @IsOptional()
66
  @ApiProperty()
67
  preloadBeforeSpaceStarts?: boolean
68

69
  // Transform properties.
70
  @IsOptional()
71
  @ApiProperty()
72
  position?: Vector3AsArray
73

74
  @IsOptional()
75
  @ApiProperty()
76
  rotation?: Vector3AsArray
77

78
  @IsOptional()
79
  @ApiProperty()
80
  scale?: Vector3AsArray
81

82
  @IsOptional()
83
  @ApiProperty()
84
  offset?: Vector3AsArray
85

86
  // Physics properties.
87
  @IsOptional()
88
  @ApiProperty()
89
  collisionEnabled?: boolean
90

91
  @IsOptional()
92
  @IsString()
93
  @ApiProperty()
94
  shapeType?: string
95

96
  @IsOptional()
97
  @IsString()
98
  @ApiProperty()
99
  bodyType?: string
100

101
  // Deprecated but kept for compat, remove in the future.
102
  @IsOptional()
103
  @ApiProperty()
104
  staticEnabled?: boolean
105

106
  @IsOptional()
107
  @ApiProperty()
108
  massKg?: number
109

110
  @IsOptional()
111
  @ApiProperty()
112
  gravityScale?: number
113

114
  // Visibility properties
115
  @IsOptional()
116
  @IsBoolean()
117
  @ApiProperty()
118
  castShadows?: boolean
119

120
  @IsOptional()
121
  @IsNumber()
122
  @ApiProperty()
123
  visibleFrom?: number
124

125
  @IsOptional()
126
  @IsNumber()
127
  @ApiProperty()
128
  visibleTo?: number
129

130
  @IsOptional()
131
  @IsNumber()
132
  @ApiProperty()
133
  visibleFromMargin?: number
134

135
  @IsOptional()
136
  @IsNumber()
137
  @ApiProperty()
138
  visibleToMargin?: number
139

140
  // Material property. This references an Asset
141
  @IsOptional()
142
  @ApiProperty()
143
  materialAssetId?: string
144

145
  // Instance material properties. Defines the set of material parameters
146
  // that can be changed per individual SpaceObject instance
147
  @IsOptional()
148
  @ApiProperty()
149
  objectColor?: Vector4AsArray
150

151
  @IsOptional()
152
  @ApiProperty()
153
  objectTexture?: string
154

155
  /**
156
   * @deprecated
157
   * @description objectTextureSize was updated to Vector3. New property: objectTextureSizeV2. 2023-04-17
158
   */
159
  @IsOptional()
160
  @ApiProperty()
161
  objectTextureSize?: number
162

163
  @IsOptional()
164
  @ApiProperty()
165
  objectTextureSizeV2?: Vector3AsArray
166

167
  @IsOptional()
168
  @ApiProperty()
169
  objectTextureOffset?: Vector3AsArray
170

171
  @IsOptional()
172
  @ApiProperty()
173
  objectTextureTriplanar?: boolean
174

175
  @IsOptional()
176
  @ApiProperty()
177
  objectTextureRepeat?: boolean
178

179
  // Audio properties.
180
  @IsOptional()
181
  @ApiProperty()
182
  audioAutoPlay?: boolean
183

184
  @IsOptional()
185
  @ApiProperty()
186
  audioLoop?: boolean
187

188
  @IsOptional()
189
  @ApiProperty()
190
  audioIsSpatial?: boolean
191

192
  @IsOptional()
193
  @ApiProperty()
194
  audioPitch?: number
195

196
  @IsOptional()
197
  @ApiProperty()
198
  audioBaseVolume?: number
199

200
  @IsOptional()
201
  @ApiProperty()
202
  audioSpatialMaxVolume?: number
203

204
  @IsOptional()
205
  @ApiProperty()
206
  audioSpatialRange?: number
207

208
  @IsOptional()
209
  @IsArray()
210
  @ApiProperty()
211
  surfaceMaterialId?: any[]
212

213
  @IsOptional()
214
  @IsArray()
215
  @ApiProperty()
216
  scriptEvents?: any[]
217

218
  @IsOptional()
219
  @IsArray()
220
  @ApiProperty()
221
  extraNodes?: any[]
222
}
223

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.