universo-platform-3d

Форк
0
196 строк · 4.1 Кб
1
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2
import { ApiProperty } from '@nestjs/swagger'
3
import * as mongoose from 'mongoose'
4
import { Document } from 'mongoose'
5
import { Role, RoleSchema } from '../roles/models/role.schema'
6
import { ISchemaWithRole } from '../roles/role-consumer.interface'
7
import { AssetPublicData } from './asset.schema'
8
import { Material } from './material.schema'
9
import { Asset } from '../asset/asset.schema'
10
import { Vector4AsArray } from '../option-sets/vectors'
11

12
// Properties must not be undefined so that getPublicPropertiesForMongooseQuery can work
13
export class MapPublicData extends AssetPublicData {
14
  @ApiProperty({
15
    example: 'Concrete_super_shiny_example'
16
  })
17
  mapName = ''
18
  @ApiProperty()
19
  heightmapAssetId = ''
20
  @ApiProperty()
21
  flatMaterialAssetId = ''
22
  @ApiProperty()
23
  cliffMaterialAssetId = ''
24
  @ApiProperty()
25
  mapSize = 512
26
  @ApiProperty()
27
  mapPrecision = 1.0
28
  @ApiProperty()
29
  heightScale = 32.0
30
  @ApiProperty()
31
  layerOffset = 0.0
32
  @ApiProperty()
33
  flatUVScale = 1.0
34
  @ApiProperty()
35
  cliffUVScale = 1.0
36
  @ApiProperty()
37
  flatCliffRatio = -0.6
38
  @ApiProperty()
39
  flatColor = [1.0, 1.0, 1.0, 1.0]
40
  @ApiProperty()
41
  cliffColor = [1.0, 1.0, 1.0, 1.0]
42
  @ApiProperty()
43
  colormapAssetId = ''
44
  @ApiProperty()
45
  colormapStrength = 1.0
46
}
47

48
export type MapDocument = MapAsset & Document
49

50
@Schema({
51
  timestamps: true,
52
  toJSON: {
53
    virtuals: true
54
  }
55
  // discriminatorKey: __t <- don't uncomment this line: this line is to note that __t is the Mongoose default discriminator key that we use for simplicity rather than specifying our own discriminator key. When this schema is instantiated, __t is "MapAsset". This is DIFFERENT from assetType since we hadn't been using discriminators up until 2023-02-04 18:49:52. See https://mongoosejs.com/docs/discriminators.html#discriminator-keys. Walkthrough: https://www.loom.com/share/7e09d2777ef94368bcd5fd8c8341b5ef
56
})
57
export class MapAsset {
58
  _id: string
59
  @Prop({
60
    trim: true,
61
    required: true
62
  })
63
  @ApiProperty({
64
    example: 'Mountain_hill_example'
65
  })
66
  mapName: string
67

68
  /**
69
   * Optional properties
70
   */
71
  @Prop({
72
    required: false,
73
    type: mongoose.Schema.Types.ObjectId,
74
    ref: 'Asset'
75
  })
76
  @ApiProperty()
77
  heightmapAssetId?: Asset
78

79
  @Prop({
80
    required: false,
81
    type: mongoose.Schema.Types.ObjectId,
82
    ref: 'Material'
83
  })
84
  @ApiProperty()
85
  flatMaterialAssetId?: Material
86

87
  @Prop({
88
    required: false,
89
    type: mongoose.Schema.Types.ObjectId,
90
    ref: 'Material'
91
  })
92
  @ApiProperty()
93
  cliffMaterialAssetId?: Material
94

95
  @Prop({
96
    required: false,
97
    default: 512.0,
98
    type: Number
99
  })
100
  @ApiProperty()
101
  mapSize?: number
102

103
  @Prop({
104
    required: false,
105
    default: 1.0,
106
    type: Number
107
  })
108
  @ApiProperty()
109
  mapPrecision?: number
110

111
  @Prop({
112
    required: false,
113
    default: 32.0,
114
    type: Number
115
  })
116
  @ApiProperty()
117
  heightScale?: number
118

119
  @Prop({
120
    required: false,
121
    default: 32.0,
122
    type: Number
123
  })
124
  @ApiProperty()
125
  layerOffset?: number
126

127
  @Prop({
128
    required: false,
129
    default: 1.0,
130
    type: Number
131
  })
132
  @ApiProperty()
133
  flatUVScale?: number
134

135
  @Prop({
136
    required: false,
137
    default: 1.0,
138
    type: Number
139
  })
140
  @ApiProperty()
141
  cliffUVScale?: number
142

143
  @Prop({
144
    required: false,
145
    default: -0.6
146
  })
147
  @ApiProperty()
148
  flatCliffRatio?: number
149

150
  @Prop({
151
    required: false,
152
    type: mongoose.Types.Array,
153
    default: [1.0, 1.0, 1.0, 1.0]
154
  })
155
  @ApiProperty()
156
  flatColor?: Vector4AsArray
157

158
  @Prop({
159
    required: false,
160
    type: mongoose.Types.Array,
161
    default: [1.0, 1.0, 1.0, 1.0]
162
  })
163
  @ApiProperty()
164
  cliffColor?: Vector4AsArray
165

166
  @Prop({
167
    required: false,
168
    type: mongoose.Schema.Types.ObjectId,
169
    ref: 'Material'
170
  })
171
  @ApiProperty()
172
  colormapAssetId?: mongoose.Schema.Types.ObjectId
173

174
  @Prop({
175
    required: false,
176
    default: 0.5,
177
    type: Number
178
  })
179
  @ApiProperty()
180
  colormapStrength?: number
181

182
  /**
183
   * START Section: ISchemaWithRole implementer
184
   */
185
  @Prop({
186
    required: true,
187
    type: RoleSchema
188
  })
189
  @ApiProperty()
190
  role: Role
191
  /**
192
   * END Section: ISchemaWithRole implementer
193
   */
194
}
195

196
export const MapSchema = SchemaFactory.createForClass(MapAsset)
197

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

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

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

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