12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package api
- import (
- "mats/db/model"
- "mats/db/repo"
- funcgraph "mats/funcGraph"
- "time"
- "go.mongodb.org/mongo-driver/bson"
- "go.mongodb.org/mongo-driver/bson/primitive"
- )
- func UploadEnv3d(apictx *ApiSession, dbConf *model.AssetDbConf, body *model.AssetEnv3dHdr) (interface{}, error) {
- asset := body
- source := asset.Source
- asset.Enable = BoolValue(false)
- if source == nil || source.File.Size < 1 || len(source.File.Url) < 1 {
- asset.AssetState = model.AssetState_Empty
- } else {
- asset.AssetState = model.AssetState_Waiting
- // asset.Source.ToneMap = &model.ToneMap{
- // Method: Int32Value(1),
- // Exposure: Float64Value(1),
- // Brightness: Float64Value(0.1),
- // Contrast: Float64Value(0.06),
- // Saturation: Float64Value(1),
- // }
- // asset.Source.Options = &model.Env3dOption{
- // Rotation: 0,
- // Exposure: 1,
- // }
- }
- asset.CreateTime = time.Now()
- asset.UpdateTime = time.Now()
- collectionName := dbConf.AssetConf.Collection
- assetId, err := repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset)
- if err != nil {
- return nil, err
- }
- if asset.AssetState == model.AssetState_Waiting { //模型转换请求
- err = funcgraph.CreateHdr(source.File.Url, assetId, dbConf.Db.Name, dbConf.AssetConf.Collection)
- if err != nil {
- update := bson.M{"$set": bson.M{"assetState": model.AssetState_Failed}}
- repo.RepoUpdateSetDbDocProps(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, assetId, update)
- }
- }
- return assetId, err
- }
- func UpdateHdrComm(apictx *ApiSession, dbConf *model.AssetDbConf, body *model.AssetEnv3dHdr) (interface{}, error) {
- asset := body
- asset.UpdateTime = time.Now()
- id := asset.Id.Hex()
- asset.Id = primitive.NilObjectID
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
- }
- func UpdateHdrSource(apictx *ApiSession, dbConf *model.AssetDbConf, body *model.AssetEnv3dHdr) (interface{}, error) {
- asset := body
- asset.UpdateTime = time.Now()
- id := asset.Id.Hex()
- asset.Id = primitive.NilObjectID
- collectionName := dbConf.AssetConf.Collection
- return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
- }
|