This commit is contained in:
parent
574778f49a
commit
95edd42273
|
|
@ -25,6 +25,9 @@ app.use("/render/game", require("./routes/render/game.js"))
|
||||||
app.use("/render/headshot", require("./routes/render/headshot.js"))
|
app.use("/render/headshot", require("./routes/render/headshot.js"))
|
||||||
app.use("/render/bodyshot", require("./routes/render/bodyshot.js"))
|
app.use("/render/bodyshot", require("./routes/render/bodyshot.js"))
|
||||||
|
|
||||||
|
app.use("/render/3d/asset", require("./routes/render/3d/asset.js"))
|
||||||
|
app.use("/render/3d/user", require("./routes/render/3d/user.js"))
|
||||||
|
|
||||||
app.use("*", require("./routes/index.js"))
|
app.use("*", require("./routes/index.js"))
|
||||||
|
|
||||||
app.listen(process.env.PORT || 64989, () => {
|
app.listen(process.env.PORT || 64989, () => {
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,13 @@ class RenderJob extends Job {
|
||||||
return Buffer.from(result[0]?.OpenJobExResult?.LuaValue[0]?.value, "base64")
|
return Buffer.from(result[0]?.OpenJobExResult?.LuaValue[0]?.value, "base64")
|
||||||
}
|
}
|
||||||
|
|
||||||
async RenderBodyshot(id, base64 = false) {
|
async RenderBodyshot(id, base64 = false, three_d = false) {
|
||||||
const started = await this.Start()
|
const started = await this.Start()
|
||||||
if (!started) throw new Error("RCCService failed to start")
|
if (!started) throw new Error("RCCService failed to start")
|
||||||
if (!this.client) await this.CreateClient()
|
if (!this.client) await this.CreateClient()
|
||||||
|
|
||||||
logger.info(`[${this.id}] Bodyshot RenderJob started for ${id}`)
|
if (three_d) logger.info(`[${this.id}] 3D Bodyshot RenderJob started for ${id}`)
|
||||||
|
else logger.info(`[${this.id}] Bodyshot RenderJob started for ${id}`)
|
||||||
|
|
||||||
const result = await this.OpenJobEx({
|
const result = await this.OpenJobEx({
|
||||||
name: this.id,
|
name: this.id,
|
||||||
|
|
@ -58,7 +59,7 @@ class RenderJob extends Job {
|
||||||
{ type: "LUA_TSTRING", value: this.id },
|
{ type: "LUA_TSTRING", value: this.id },
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: "Bodyshot" },
|
{ type: "LUA_TSTRING", value: "Bodyshot" },
|
||||||
{ type: "LUA_TSTRING", value: process.env.RENDER_FORMAT },
|
{ type: "LUA_TSTRING", value: three_d ? "OBJ" : process.env.RENDER_FORMAT },
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_WIDTH },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_WIDTH },
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_HEIGHT },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_HEIGHT },
|
||||||
|
|
@ -69,21 +70,23 @@ class RenderJob extends Job {
|
||||||
},
|
},
|
||||||
}).catch((e) => false)
|
}).catch((e) => false)
|
||||||
|
|
||||||
logger.info(`[${this.id}] Bodyshot RenderJob finished for ${id}`)
|
if (three_d) logger.info(`[${this.id}] 3D Bodyshot RenderJob finished for ${id}`)
|
||||||
|
else logger.info(`[${this.id}] Bodyshot RenderJob finished for ${id}`)
|
||||||
|
|
||||||
await this.Stop()
|
await this.Stop()
|
||||||
|
|
||||||
if (!result) return false
|
if (!result) return false
|
||||||
if (base64) return result[0].OpenJobExResult.LuaValue[0].value
|
if (base64 || three_d) return result[0].OpenJobExResult.LuaValue[0].value
|
||||||
return Buffer.from(result[0]?.OpenJobExResult?.LuaValue[0]?.value, "base64")
|
return Buffer.from(result[0]?.OpenJobExResult?.LuaValue[0]?.value, "base64")
|
||||||
}
|
}
|
||||||
|
|
||||||
async RenderAsset(id, base64 = false) {
|
async RenderAsset(id, base64 = false, three_d = false) {
|
||||||
const started = await this.Start()
|
const started = await this.Start()
|
||||||
if (!started) throw new Error("RCCService failed to start")
|
if (!started) throw new Error("RCCService failed to start")
|
||||||
if (!this.client) await this.CreateClient()
|
if (!this.client) await this.CreateClient()
|
||||||
|
|
||||||
logger.info(`[${this.id}] Asset RenderJob started for ${id}`)
|
if (three_d) logger.info(`[${this.id}] 3D Asset RenderJob started for ${id}`)
|
||||||
|
else logger.info(`[${this.id}] Asset RenderJob started for ${id}`)
|
||||||
|
|
||||||
const result = await this.OpenJobEx({
|
const result = await this.OpenJobEx({
|
||||||
name: this.id,
|
name: this.id,
|
||||||
|
|
@ -93,7 +96,7 @@ class RenderJob extends Job {
|
||||||
{ type: "LUA_TSTRING", value: this.id },
|
{ type: "LUA_TSTRING", value: this.id },
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: "Asset" },
|
{ type: "LUA_TSTRING", value: "Asset" },
|
||||||
{ type: "LUA_TSTRING", value: process.env.RENDER_FORMAT },
|
{ type: "LUA_TSTRING", value: three_d ? "OBJ" : process.env.RENDER_FORMAT },
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_WIDTH },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_WIDTH },
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_HEIGHT },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_HEIGHT },
|
||||||
|
|
@ -105,12 +108,13 @@ class RenderJob extends Job {
|
||||||
},
|
},
|
||||||
}).catch((e) => false)
|
}).catch((e) => false)
|
||||||
|
|
||||||
logger.info(`[${this.id}] Asset RenderJob finished for ${id}`)
|
if (three_d) logger.info(`[${this.id}] 3D Asset RenderJob finished for ${id}`)
|
||||||
|
else logger.info(`[${this.id}] Asset RenderJob finished for ${id}`)
|
||||||
|
|
||||||
await this.Stop()
|
await this.Stop()
|
||||||
|
|
||||||
if (!result) return false
|
if (!result) return false
|
||||||
if (base64) return result[0].OpenJobExResult.LuaValue[0].value
|
if (base64 || three_d) return result[0].OpenJobExResult.LuaValue[0].value
|
||||||
return Buffer.from(result[0]?.OpenJobExResult?.LuaValue[0]?.value, "base64")
|
return Buffer.from(result[0]?.OpenJobExResult?.LuaValue[0]?.value, "base64")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
|
|
||||||
local Player = game.Players:CreateLocalPlayer(0)
|
local Player = game.Players:CreateLocalPlayer(0)
|
||||||
Player.CharacterAppearance = ("%s/Character?id=%d"):format(baseUrl, assetId)
|
Player.CharacterAppearance = ("%s/users/%d/character"):format(baseUrl, assetId)
|
||||||
Player:LoadCharacter(false)
|
Player:LoadCharacter(false)
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
const express = require("express")
|
||||||
|
const app = express.Router()
|
||||||
|
|
||||||
|
const RenderJob = require("../../../lib/classes/RenderJob.js")
|
||||||
|
|
||||||
|
app.get("/:id", async (request, response) => {
|
||||||
|
const job = new RenderJob()
|
||||||
|
const result = await job.RenderAsset(request.params.id, process.env.RENDER_BASE64, true).catch((_) => _)
|
||||||
|
|
||||||
|
if (result?.message) return response.status(500).json({ error: result.message })
|
||||||
|
else return response.end(result)
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = app
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
const express = require("express")
|
||||||
|
const app = express.Router()
|
||||||
|
|
||||||
|
const RenderJob = require("../../../lib/classes/RenderJob.js")
|
||||||
|
|
||||||
|
app.get("/:id", async (request, response) => {
|
||||||
|
const job = new RenderJob()
|
||||||
|
const result = await job.RenderBodyshot(request.params.id, process.env.RENDER_BASE64, true).catch((_) => _)
|
||||||
|
|
||||||
|
if (result?.message) return response.status(500).json({ error: result.message })
|
||||||
|
else return response.end(result)
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = app
|
||||||
Loading…
Reference in New Issue