From 73bab4a2e3c5eeb1f9a41b46589eeefb0069c39b Mon Sep 17 00:00:00 2001 From: MickaelK Date: Tue, 29 Apr 2025 13:42:41 +1000 Subject: [PATCH] feature (3d): handle mesh files --- config/mime.json | 1 + server/plugin/plg_application_3d/Makefile | 4 ++++ server/plugin/plg_application_3d/index_mesh.js | 17 +++++++++++++++++ server/plugin/plg_application_3d/manifest.json | 6 ++++++ 4 files changed, 28 insertions(+) create mode 100644 server/plugin/plg_application_3d/index_mesh.js diff --git a/config/mime.json b/config/mime.json index 8b1dc2fe..07b7e69b 100644 --- a/config/mime.json +++ b/config/mime.json @@ -100,6 +100,7 @@ "md": "text/markdown", "mdc": "image/x-minolta-mdc", "mef": "image/x-mamiya-mef", + "mesh": "model/mesh", "mid": "audio/midi", "midi": "application/x-midi", "mjs": "application/javascript", diff --git a/server/plugin/plg_application_3d/Makefile b/server/plugin/plg_application_3d/Makefile index af524b76..209bd055 100644 --- a/server/plugin/plg_application_3d/Makefile +++ b/server/plugin/plg_application_3d/Makefile @@ -4,3 +4,7 @@ all: install: zip -r application_3d.zip . mv application_3d.zip ../../../dist/data/state/plugins/application_3d.zip + +deps_mesh: + [ -d vendor ] || mkdir vendor + curl https://gist.githubusercontent.com/mickael-kerjean/9a517f95112410fcacaad8563c1ba314/raw/ab483b38aebb7048832aad7b342f9161dd928e49/gistfile1.txt > vendor/MeshLoader.js diff --git a/server/plugin/plg_application_3d/index_mesh.js b/server/plugin/plg_application_3d/index_mesh.js new file mode 100644 index 00000000..c335495d --- /dev/null +++ b/server/plugin/plg_application_3d/index_mesh.js @@ -0,0 +1,17 @@ +export default async function(I3D, { THREE }) { + const module = await import("./vendor/MeshLoader.js"); + + return class Impl extends I3D { + constructor() { + super(); + } + + load(url, onLoad, onProgress, onError) { + return (new module.MeshLoader()).load(url, onLoad, onProgress, onError); + } + + transform(obj) { + return obj; + } + } +} diff --git a/server/plugin/plg_application_3d/manifest.json b/server/plugin/plg_application_3d/manifest.json index 1ce8ebdf..00776dc2 100644 --- a/server/plugin/plg_application_3d/manifest.json +++ b/server/plugin/plg_application_3d/manifest.json @@ -37,6 +37,12 @@ "mime": "model/step", "entrypoint": "/index_step.js", "application": "3d" + }, + { + "type": "xdg-open", + "mime": "model/mesh", + "entrypoint": "/index_mesh.js", + "application": "3d" } ] }