123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- package model
- import (
- "time"
- "infish.cn/comm"
- "go.mongodb.org/mongo-driver/bson/primitive"
- )
- const (
- AssetTypeMesh = 10 //"mesh" //模型
- AssetTypeImage = 20 //"image" //图片
- AssetTypeMaterial = 30 //"material" //材质球
- AssetTypeMaterialGroup = 31 //"material" //材质球组
- AssetTypeEnv3d = 40 //"hdr " //环境球
- AssetTypePackage = 50 //"package " //3d资产包
- AssetState_Empty = 0
- AssetState_Waiting = 100 //等待处理
- AssetState_Proccing = 101 //正在处理
- AssetState_Failed = 102 //处理失败!
- AssetState_Succ = 200 //处理成功
- )
- type DatabaseAssetV0 struct {
- Id primitive.ObjectID `bson:"_id,omitempty" json:"_id"` //数据库Id
- UserId string `bson:"userId,omitempty" json:"userId"` //数据库Id
- Name string `bson:"name,omitempty" json:"name"` //数据库名字
- Label string `bson:"label,omitempty" json:"label"` //前端展示标签
- CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
- Categories *comm.DbCategory `bson:"categories,omitempty" json:"categories"` //数据的分类
- Assets *comm.DbAsset `bson:"assets,omitempty" json:"assets"` //资产定义
- }
- type Obb struct {
- Min Vec3Obj `bson:"min,omitempty" json:"min"`
- Max Vec3Obj `bson:"max,omitempty" json:"max"`
- }
- type StaticMesh struct {
- Id primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
- OwnerId primitive.ObjectID `bson:"ownerId,omitempty" json:"ownerId,omitempty"`
- Name string `bson:"name,omitempty" json:"name"`
- CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
- UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
- State int `bson:"state,omitempty" json:"state"` //created completed published
- Thumbnail *OssType `bson:"thumbnail,omitempty" json:"thumbnail"`
- Categories []string `bson:"categories,omitempty" json:"categories,omitempty"` //所属分类Id
- Components []*MeshMatConf `bson:"components,omitempty" json:"components"`
- Osgjs *OssType `bson:"osgjs,omitempty" json:"osgjs"`
- File *OssType `bson:"file,omitempty" json:"file"` //hdr or fbx
- Shadow *OssType `bson:"shadow,omitempty" json:"shadow,omitempty"`
- Obb *Obb `bson:"obb,omitempty" json:"obb,omitempty"`
- }
- type AssetBase struct {
- OwnerId primitive.ObjectID `bson:"ownerId,omitempty" json:"ownerId,omitempty"`
- Name string `bson:"name,omitempty" json:"name"`
- CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
- UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
- Thumbnail *OssType `bson:"thumbnail,omitempty" json:"thumbnail"`
- Categories []string `bson:"categories,omitempty" json:"categories"` //所属分类Id
- TaskId string `bson:"taskId,omitempty" json:"taskId"` //资产处理id
- AssetState int `bson:"assetState,omitempty" json:"assetState"`
- Enable *bool `bson:"enable,omitempty" json:"enable"` //是否有效!
- }
- type StaticMeshSource struct {
- Components []*MeshMatConf `bson:"components,omitempty" json:"components"`
- Osgjs *OssType `bson:"osgjs,omitempty" json:"osgjs"`
- File *OssType `bson:"file,omitempty" json:"file"` //hdr or fbx
- Glb *OssType `bson:"glb,omitempty" json:"glb"` //hdr or fbx
- Shadow *OssType `bson:"shadow,omitempty" json:"shadow,omitempty"`
- BoundingBox *Obb `bson:"boundingBox,omitempty" json:"boundingBox,omitempty"`
- }
- type HdrSource struct {
- Config *Evn3dHdrConf `bson:"config,omitempty" json:"config"`
- File *OssType `bson:"file,omitempty" json:"file"` //hdr or fbx
- Options *Env3dOption `bson:"options,omitempty" json:"options"`
- ToneMap *ToneMap `bson:"toneMap,omitempty" json:"toneMap"`
- }
- type ImageSource struct {
- File *OssType `bson:"file,omitempty" json:"file"` //hdr or fbx
- }
- type AssetUserInfo struct {
- Name string `bson:"name,omitempty" json:"name"`
- Thumbnail *OssType `bson:"thumbnail,omitempty" json:"thumbnail"`
- }
- type IAsset interface {
- SetIdEmpty()
- ResetCreateTime()
- SetOwner(id string, otype string)
- SetAssetType(atype string)
- SetUserInfo(id string, info *comm.AssetUserInfo)
- }
- type AssetStaticMesh struct {
- Id primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
- UserId primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"` //用户Id
- UserInfo *comm.AssetUserInfo `bson:"userInfo,omitempty" json:"userInfo,omitempty"` //用户Id
- OwnerId primitive.ObjectID `bson:"ownerId,omitempty" json:"ownerId,omitempty"` //userId teamId companyId
- OwnerType string `bson:"ownerType,omitempty" json:"ownerType,omitempty"` //user team company
- AssetType string `bson:"assetType,omitempty" json:"assetType,omitempty"` //user team company
- Name string `bson:"name,omitempty" json:"name"`
- CusNum string `bson:"cusNum,omitempty" json:"cusNum,omitempty"` //型号
- CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
- UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
- Thumbnail *OssType `bson:"thumbnail,omitempty" json:"thumbnail"`
- Categories []string `bson:"categories,omitempty" json:"categories"` //所属分类Id
- CusCategories []string `bson:"cusCategories,omitempty" json:"cusCategories"` //用户自定义分类
- TaskId string `bson:"taskId,omitempty" json:"taskId"` //资产处理id
- AssetState int `bson:"assetState,omitempty" json:"assetState"`
- Enable *bool `bson:"enable,omitempty" json:"enable"` //是否有效!
- Source *StaticMeshSource `bson:"source,omitempty" json:"source,omitempty"`
- UserData interface{} `bson:"userData,omitempty" json:"userData,omitempty"` //用户数据
- }
- func (s *AssetStaticMesh) SetIdEmpty() {
- s.Id = primitive.NilObjectID
- }
- func (s *AssetStaticMesh) ResetCreateTime() {
- s.CreateTime = time.Now()
- s.UpdateTime = time.Now()
- }
- func (s *AssetStaticMesh) SetOwner(id string, otype string) {
- s.OwnerId, _ = primitive.ObjectIDFromHex(id)
- s.OwnerType = otype
- }
- func (s *AssetStaticMesh) SetUserInfo(id string, info *comm.AssetUserInfo) {
- s.UserId, _ = primitive.ObjectIDFromHex(id)
- s.UserInfo = info
- }
- func (s *AssetStaticMesh) SetAssetType(otype string) {
- s.AssetType = otype
- }
- type AssetMat struct {
- Id primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
- UserId primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"` //用户Id
- UserInfo *comm.AssetUserInfo `bson:"userInfo,omitempty" json:"userInfo,omitempty"` //用户Id
- OwnerId primitive.ObjectID `bson:"ownerId,omitempty" json:"ownerId,omitempty"`
- OwnerType string `bson:"ownerType,omitempty" json:"ownerType,omitempty"` //user team company
- AssetType string `bson:"assetType,omitempty" json:"assetType,omitempty"` //user team company
- CusNum string `bson:"cusNum,omitempty" json:"cusNum,omitempty"` //型号
- Name string `bson:"name,omitempty" json:"name"`
- CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
- UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
- Thumbnail *OssType `bson:"thumbnail,omitempty" json:"thumbnail"`
- Categories []string `bson:"categories,omitempty" json:"categories"` //所属分类Id
- TaskId string `bson:"taskId,omitempty" json:"taskId"` //资产处理id
- AssetState int `bson:"assetState,omitempty" json:"assetState"`
- Enable *bool `bson:"enable,omitempty" json:"enable"` //是否有效!
- Source *MatConfig `bson:"source,omitempty" json:"source,omitempty"`
- UserData interface{} `bson:"userData,omitempty" json:"userData,omitempty"` //用户数据
- }
- func (s *AssetMat) SetIdEmpty() {
- s.Id = primitive.NilObjectID
- }
- func (s *AssetMat) ResetCreateTime() {
- s.CreateTime = time.Now()
- s.UpdateTime = time.Now()
- }
- func (s *AssetMat) SetOwner(id string, otype string) {
- s.OwnerId, _ = primitive.ObjectIDFromHex(id)
- s.OwnerType = otype
- }
- func (s *AssetMat) SetAssetType(otype string) {
- s.AssetType = otype
- }
- func (s *AssetMat) SetUserInfo(id string, info *comm.AssetUserInfo) {
- s.UserId, _ = primitive.ObjectIDFromHex(id)
- s.UserInfo = info
- }
|