universo-platform-3d

Форк
0
110 строк · 2.8 Кб
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 { Texture } from './texture.schema'
9

10
// Properties must not be undefined so that getPublicPropertiesForMongooseQuery can work
11
export class MaterialPublicData extends AssetPublicData {
12
  @ApiProperty({
13
    example: 'Concrete_super_shiny_example'
14
  })
15
  materialName = ''
16
  @ApiProperty()
17
  materialTransparencyMode = ''
18
  @ApiProperty()
19
  materialTransparencyProperties = ''
20
  @ApiProperty()
21
  textures = []
22
  @ApiProperty()
23
  externalAssetIds = []
24
  @ApiProperty()
25
  parameters = {}
26
  @ApiProperty()
27
  materialType = ''
28
}
29

30
export type MaterialDocument = Material & Document
31

32
@Schema({
33
  timestamps: true,
34
  toJSON: {
35
    virtuals: true
36
  }
37
  // 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 "Material". 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
38
})
39
export class Material {
40
  _id: string
41
  @Prop({
42
    trim: true
43
  })
44
  @ApiProperty({
45
    example: 'Concrete_super_shiny_example'
46
  })
47
  materialName: string
48

49
  /**
50
   * @deprecated This is now a custom setting dependant on material type
51
   * @date 2023-09-29
52
   */
53
  @Prop({
54
    trim: true
55
  })
56
  @ApiProperty()
57
  materialTransparencyMode: string
58

59
  /**
60
   * @deprecated This is now a custom setting dependant on material type
61
   * @date 2023-09-29
62
   */
63
  @Prop({
64
    trim: true
65
  })
66
  @ApiProperty()
67
  materialTransparencyProperties: string
68

69
  /**
70
   * @deprecated This information is contained in external_asset_ids
71
   * @date 2023-09-29
72
   */
73
  @Prop({ type: [mongoose.Schema.Types.ObjectId], ref: 'Texture' })
74
  @ApiProperty()
75
  textures: Texture[]
76

77
  @Prop({ type: [mongoose.Schema.Types.ObjectId], ref: 'Texture' })
78
  @ApiProperty()
79
  externalAssetIds: Texture[]
80

81
  @Prop({ type: mongoose.Schema.Types.Map })
82
  @ApiProperty()
83
  parameters: any
84

85
  @Prop({
86
    required: false,
87
    trim: true
88
  })
89
  @ApiProperty()
90
  materialType: string
91

92
  @Prop()
93
  @ApiProperty()
94
  code: string
95

96
  /**
97
   * START Section: ISchemaWithRole implementer
98
   */
99
  @Prop({
100
    required: true,
101
    type: RoleSchema
102
  })
103
  @ApiProperty()
104
  role: Role
105
  /**
106
   * END Section: ISchemaWithRole implementer
107
   */
108
}
109

110
export const MaterialSchema = SchemaFactory.createForClass(Material)
111

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

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

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

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