package api import ( "assetcenter/conf" "assetcenter/db/model" "assetcenter/db/repo" "time" "go.mongodb.org/mongo-driver/bson/primitive" "infish.cn/comm" ) func UploadEnv3d(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.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 { // !hdr 无效,直接成功 // asset.AssetState = model.AssetState_Waiting asset.AssetState = model.AssetState_Succ // 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() if conf.AppConfig.IsSaveLocal() { asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl) } // assetSource := asset.Source collectionName := dbConf.AssetConf.Collection assetId, err := repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset) if err != nil { return nil, err } // !hdr 没用上 // if asset.AssetState == model.AssetState_Waiting { //模型转换请求 // url, err := bus.NatsCenter.RequestConfig("bus-network") // if err != nil { // return nil, err // } // err = funcgraph.CreateHdr(assetSource.File.Url, assetId, dbConf.Db.Name, dbConf.AssetConf.Collection, url) // 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 *comm.AssetDbConf, body *comm.AssetEnv3dHdr) (interface{}, error) { asset := body asset.UpdateTime = time.Now() id := asset.Id.Hex() asset.Id = primitive.NilObjectID if conf.AppConfig.IsSaveLocal() { asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl) } collectionName := dbConf.AssetConf.Collection return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset) } func UpdateHdrSource(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetEnv3dHdr) (interface{}, error) { asset := body asset.UpdateTime = time.Now() id := asset.Id.Hex() asset.Id = primitive.NilObjectID if conf.AppConfig.IsSaveLocal() { asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl) } collectionName := dbConf.AssetConf.Collection return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset) }