fix url paths to make JML rooms more portable

This commit is contained in:
Leon van Kammen 2026-01-29 10:49:30 +01:00
parent 677dab8abd
commit 22554eac5c
4 changed files with 11 additions and 269 deletions

View file

@ -112,7 +112,7 @@ begin
if ext.match(/(mp3|ogg)/i)
audiovisual = model_file ? false : true
base = File.basename(resource['path'], ext)
soundtrackUrl = addLink("model_files/#{resource["path"]}")
soundtrackUrl = addLink("#{resource["path"]}")
assets += " <assetsound id=\"soundtrack\" src=\"#{soundtrackUrl}\"/>\n"
objects += "<sound id=\"soundtrack\" loop=\"true\"/>\n"
end
@ -124,7 +124,7 @@ begin
audiovisual = model_file ? false : true
base = File.basename(resource['path'], ext)
videoSrc = addLink("model_files/#{resource["path"]}")
videoSrc = addLink("#{resource["path"]}")
assets += "<assetimage id=\"image\" src=\"#{videoSrc}\" loop=\"true\" auto_play=\"true\"/>\n"
objects += " <Object cull_face=\"none\" id=\"rplane\" js_id=\"image\" lighting=\"false\" pos=\"0 6.5 5.5\" scale=\"4 4 1\" image_id=\"image\"/>\n"
end
@ -133,7 +133,7 @@ begin
if ext.match(/mp4/i) || ext.match(/webm/i)
audiovisual = model_file ? false : true
base = File.basename(resource['path'], ext)
videoSrc = addLink("model_files/#{resource["path"]}")
videoSrc = addLink("#{resource["path"]}")
assets += "<assetvideo id=\"video\" src=\"#{videoSrc}\" loop=\"true\" auto_play=\"true\"/>\n"
objects += " <Object cull_face=\"none\" id=\"rplane\" js_id=\"video\" lighting=\"false\" pos=\"0 6.5 5.5\" scale=\"4 4 1\" video_id=\"video\"/>\n"
end
@ -143,7 +143,7 @@ begin
# TODO: copy files from a heuristic-based folder instead hardcoding it here
startpos = "pos=\"0 0 -10\""
use_local_asset = "room5"
rplaneSrc = addLink("model_files/roundedplane.glb")
rplaneSrc = addLink("roundedplane.glb")
system("cp /root/templates/audiovisual/roundedplane.glb #{dir}/.")
assets += " <assetobject id=\"rplane\" src=\"#{rplaneSrc}\"/>\n"
objects += " <Object cull_face=\"none\" id=\"rplane\" js_id=\"text_rplane\" lighting=\"false\" pos=\"2.69 1.84 -3.37\" rotation=\"0 45 0\" scale=\"1.6 1 1\"/>\n"
@ -168,7 +168,7 @@ begin
end
if model_file
objectSrc = "model_files/#{model_file.gsub("#","%23")}"
objectSrc = "#{model_file.gsub("#","%23")}"
if ! $links.include?(objectSrc)
objectSrc = addLink(objectSrc)
assets += " <assetobject id=\"experience\" src=\"#{objectSrc}\"/>\n"

View file

@ -4,6 +4,7 @@
<% if ! @models.empty? %>
<fireboxroom>
<assets>
<assetscript src="/view/element/layout.js"/>
<assetobject src="/view/element/janus-script-peertube/asset/button.glb" id="button"/>
<assetobject src="/view/element/janus-script-peertube/asset/button.icon.glb" id="icon"/>
<assetsound src="/view/element/janus-script-peertube/asset/button.click.mp3" id="button-click"/>

View file

@ -122,7 +122,7 @@ end
jml = ""
if File.exist?(jmlfile)
jml = File.read(jmlfile)
.gsub("model_files/",model_path(@model)+"/model_files/")
.gsub(/src=(["'])(?!(?:http|\/|\.\/))(.*?)/i, "src=\\1#{model_path(@model)}/model_files/\\2")
.gsub("-->","")
.gsub("--%3E","")
end

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB