mimized scanning-frenzy [TODO: scan_libraries via dockercmd]
This commit is contained in:
parent
37ab0ced6f
commit
c29a748151
7 changed files with 151 additions and 38 deletions
|
|
@ -206,12 +206,18 @@ start_syslog(){
|
||||||
}
|
}
|
||||||
|
|
||||||
scan_libraries(){
|
scan_libraries(){
|
||||||
sleep 10 # wait for manyfold/redis to boot first
|
|
||||||
cd /usr/src/app
|
cd /usr/src/app
|
||||||
echocolor "scanning libraries"
|
echocolor "scanning libraries"
|
||||||
bin/manyfold libraries scan
|
bin/manyfold libraries scan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scan_experience(){
|
||||||
|
id=$1
|
||||||
|
cd /usr/src/app
|
||||||
|
# don't do this when all libraries are already being scanned
|
||||||
|
rails_query 'Model.find('$id').add_new_files_later(include_all_subfolders:false)'
|
||||||
|
}
|
||||||
|
|
||||||
rails_query(){
|
rails_query(){
|
||||||
cd /usr/src/app
|
cd /usr/src/app
|
||||||
echo "$*" | bin/rails console
|
echo "$*" | bin/rails console
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,7 @@ dir="$(dirname $1)"
|
||||||
cd "$dir"
|
cd "$dir"
|
||||||
echo "[v] scan (new) files of model"
|
echo "[v] scan (new) files of model"
|
||||||
id="$(basename "$dir" | sed 's/\#//g')"
|
id="$(basename "$dir" | sed 's/\#//g')"
|
||||||
cd /usr/src/app
|
# TODO: better ratelimiting
|
||||||
echo "Model.find($id).add_new_files_later()" | /usr/src/app/bin/rails console
|
test -f /tmp/.scan && test $id = "$(cat /tmp/.scan)" && exit
|
||||||
|
/manyfold/cli/manyfold.sh scan_experience $id
|
||||||
|
echo $id > /tmp/.scan
|
||||||
|
|
|
||||||
99
manyfold/root/hook.d/experience_updated/200-to-gltf.rb
Executable file
99
manyfold/root/hook.d/experience_updated/200-to-gltf.rb
Executable file
|
|
@ -0,0 +1,99 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'json'
|
||||||
|
require_relative './../../xrforge.rb'
|
||||||
|
|
||||||
|
# Check if a filename is provided
|
||||||
|
if ARGV.length != 1
|
||||||
|
puts "Usage: #{$0} <path/to/experience/somefile.xxx>"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
filename = ARGV[0]
|
||||||
|
|
||||||
|
require 'base64'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
## Updates the 'uri' of an image in a GLTF hash when a matching PNG filename is found.
|
||||||
|
##
|
||||||
|
## gltf: a parsed JSON hash from a .gltf file
|
||||||
|
## png_path: path to the PNG file to embed
|
||||||
|
##
|
||||||
|
## returns: true if updated successfully, false if not found
|
||||||
|
#def update_gltf_image(gltf, png_path)
|
||||||
|
# # Get base name (without extension)
|
||||||
|
# name = File.basename(png_path, '.png')
|
||||||
|
#
|
||||||
|
# # Find image entry with the same name
|
||||||
|
# image_entry = gltf['images']&.find { |img| img['name'] == name }
|
||||||
|
#
|
||||||
|
# unless image_entry
|
||||||
|
# warn "No image named '#{name}' found in GLTF"
|
||||||
|
# return false
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# # Read and base64-encode the PNG file
|
||||||
|
# data = File.binread(png_path)
|
||||||
|
# encoded = Base64.strict_encode64(data)
|
||||||
|
#
|
||||||
|
# # Update the URI field with the base64-encoded PNG data URI
|
||||||
|
# image_entry['uri'] = "data:image/png;base64,#{encoded}"
|
||||||
|
#
|
||||||
|
# puts "Updated image '#{name}' in GLTF"
|
||||||
|
# true
|
||||||
|
#end
|
||||||
|
|
||||||
|
|
||||||
|
begin
|
||||||
|
|
||||||
|
# Change the directory
|
||||||
|
dir = File.dirname(filename)
|
||||||
|
Dir.chdir( File.dirname(filename) )
|
||||||
|
# Read and parse the JSON file
|
||||||
|
data = JSON.parse( File.read( "datapackage.json" ) )
|
||||||
|
|
||||||
|
ext = File.extname(filename)
|
||||||
|
filenameWithoutExt = File.basename(filename, ext)
|
||||||
|
|
||||||
|
if ! XRForge::MODEL_EXT.any?( ext )
|
||||||
|
exit(0) # not a 3d file
|
||||||
|
end
|
||||||
|
|
||||||
|
logfile = File.join( File.dirname(filename), ".xrforge/log.txt" )
|
||||||
|
XRForge.log("✅ generating gltf", logfile)
|
||||||
|
gltf_path = ".xrforge/#{filenameWithoutExt}.gltf"
|
||||||
|
system("assimp export #{filename} #{gltf_path}")
|
||||||
|
system("assimp extract #{filename} | sed 's|/.*/||g'")
|
||||||
|
|
||||||
|
# Read and parse the GLTF JSON
|
||||||
|
gltf = JSON.parse(File.read(gltf_path))
|
||||||
|
|
||||||
|
# Ensure images section exists
|
||||||
|
unless gltf['images'] && gltf['images'].is_a?(Array)
|
||||||
|
abort("No 'images' array found in #{gltf_path}")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Iterate through the images array
|
||||||
|
gltf['images'].each_with_index do |img, i|
|
||||||
|
name = img['name']
|
||||||
|
next unless name && !name.empty?
|
||||||
|
|
||||||
|
old_filename = "website_img#{i}.png"
|
||||||
|
new_filename = "#{name}.png"
|
||||||
|
|
||||||
|
if File.exist?(old_filename)
|
||||||
|
XRForge.log("✅ Renaming #{old_filename} -> #{new_filename}", logfile)
|
||||||
|
File.rename(old_filename, new_filename)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
XRForge.log(" ", logfile)
|
||||||
|
|
||||||
|
rescue Errno::ENOENT
|
||||||
|
puts "File #{filename} not found"
|
||||||
|
rescue JSON::ParserError
|
||||||
|
puts "Error parsing JSON from #{filename}"
|
||||||
|
rescue => e
|
||||||
|
puts "An error occurred: #{e.message}"
|
||||||
|
end
|
||||||
|
|
||||||
2
manyfold/root/hook.d/experience_updated/300-package_godot_zip.sh
Normal file → Executable file
2
manyfold/root/hook.d/experience_updated/300-package_godot_zip.sh
Normal file → Executable file
|
|
@ -6,5 +6,5 @@ echo "[package_godot_zip.sh] zipping godot.zip"
|
||||||
# overwrite empty godot template project-zip with given URL
|
# overwrite empty godot template project-zip with given URL
|
||||||
test -n "$GODOT_TEMPLATE_ZIP" && timeout 50 wget "$GODOT_TEMPLATE_ZIP" -O ~/template_godot.zip
|
test -n "$GODOT_TEMPLATE_ZIP" && timeout 50 wget "$GODOT_TEMPLATE_ZIP" -O ~/template_godot.zip
|
||||||
|
|
||||||
cp ~/template_godot.zip package_godot.zip
|
cp ~/template_godot.zip .xrforge/godot.zip
|
||||||
zip .xrforge/godot.zip *.glb *.usdz *.obj
|
zip .xrforge/godot.zip *.glb *.usdz *.obj
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,12 @@ begin
|
||||||
<Assets>
|
<Assets>
|
||||||
<assetobject id="experience" src="#{federate_drive_host}/#{model_file.gsub("#","%23")}"/>
|
<assetobject id="experience" src="#{federate_drive_host}/#{model_file.gsub("#","%23")}"/>
|
||||||
</Assets>
|
</Assets>
|
||||||
<Room>
|
<Room #{ data['keywords'].include?('singleuser') ? "private='true'" : ""}>
|
||||||
<object pos="0 0 0" collision_id="experience" id="experience" />
|
<object pos="0 0 0" collision_id="experience" id="experience" />
|
||||||
</Room>
|
</Room>
|
||||||
</FireBoxRoom>
|
</FireBoxRoom>
|
||||||
|
<!-- archive.org hints -->
|
||||||
|
<a href="#{federate_drive_host}/#{model_file.gsub("#","%23")}"></a>
|
||||||
JML
|
JML
|
||||||
|
|
||||||
html = <<~HTML
|
html = <<~HTML
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ begin
|
||||||
# Read and parse the JSON file
|
# Read and parse the JSON file
|
||||||
data = JSON.parse( File.read( "datapackage.json" ) )
|
data = JSON.parse( File.read( "datapackage.json" ) )
|
||||||
|
|
||||||
|
logfile = File.join( File.dirname(filename), ".xrforge/log.txt" )
|
||||||
XRForge.log("✅ starting XR fragments check", logfile)
|
XRForge.log("✅ starting XR fragments check", logfile)
|
||||||
|
|
||||||
# Extract the desired field (assuming the field is named 'model_file')
|
# Extract the desired field (assuming the field is named 'model_file')
|
||||||
|
|
@ -47,16 +48,20 @@ begin
|
||||||
# Check if a model file was found after the loop
|
# Check if a model file was found after the loop
|
||||||
if model_file
|
if model_file
|
||||||
XRForge.log("✅ Final model file: '#{model_file}'", logfile)
|
XRForge.log("✅ Final model file: '#{model_file}'", logfile)
|
||||||
|
# update datapackage
|
||||||
|
if ! data['keywords'].include?('xrfragments')
|
||||||
|
data['keywords'].push('xrfragments')
|
||||||
|
File.write("datapackage.json", JSON.pretty_generate(data) )
|
||||||
|
end
|
||||||
else
|
else
|
||||||
XRForge.log("❌ No suitable 3D file found for XR Fragments-compatible experience", logfile)
|
XRForge.log("❌ No suitable 3D file found for XR Fragments-compatible experience", logfile)
|
||||||
|
# update datapackage
|
||||||
|
if data['keywords'].include?('xrfragments')
|
||||||
|
data['keywords'].delete('xrfragments')
|
||||||
|
File.write("datapackage.json", JSON.pretty_generate(data) )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
XRForge.log("✅ updating xrfragment tag", logfile)
|
||||||
# Construct the output filename
|
|
||||||
output_file = "#{File.basename(model_file, File.extname(model_file))}.blend"
|
|
||||||
|
|
||||||
# Execute the system call
|
|
||||||
puts("assimp", model_file, output_file)
|
|
||||||
system("assimp", model_file, output_file)
|
|
||||||
|
|
||||||
XRForge.log(" ", logfile)
|
XRForge.log(" ", logfile)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
<% if @num_files > 0 %>
|
<% if @num_files > 0 %>
|
||||||
<h2><a name="files"><%= t(".files") %></a></h2>
|
<h2><a name="files"><%= t(".files") %></a></h2>
|
||||||
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 mb-4">
|
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 mb-4">
|
||||||
<%= render partial: "file", collection: @groups.delete(nil) %>
|
<%= render partial: "file", collection: (@groups.delete(nil)) + @images %>
|
||||||
</div>
|
</div>
|
||||||
<% @groups.each_pair do |group, files| %>
|
<% @groups.each_pair do |group, files| %>
|
||||||
<h3><a name="<%= group.parameterize %>"><%= group.strip.careful_titleize %>*</a></h3>
|
<h3><a name="<%= group.parameterize %>"><%= group.strip.careful_titleize %>*</a></h3>
|
||||||
|
|
@ -83,30 +83,30 @@
|
||||||
<% if ENV['FEDERATE_DRIVE_HOST'].present? %>
|
<% if ENV['FEDERATE_DRIVE_HOST'].present? %>
|
||||||
|
|
||||||
<% if @model.tags.where(name: "janusxr" ).any? %>
|
<% if @model.tags.where(name: "janusxr" ).any? %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<img src="/assets/janusxr.svg" style="width: 16px; transform: translate(0px,-2px);">
|
<img src="/assets/janusxr.svg" style="width: 16px; transform: translate(0px,-2px);">
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%
|
<%
|
||||||
fediURL = ENV['FEDERATE_DRIVE_HOST']+"/"+@model.library.name+"/"+@model.path.gsub("#","%23")+"/.xrforge/janusxr.html"
|
fediURL = ENV['FEDERATE_DRIVE_HOST']+"/"+@model.library.name+"/"+@model.path.gsub("#","%23")+"/.xrforge/janusxr.html"
|
||||||
%>
|
%>
|
||||||
<%= link_to "JanusXR address", fediURL, target:"_blank" %>
|
<%= link_to "JanusXR address", fediURL, target:"_blank" %>
|
||||||
<a href="" target="_blank"><i class="bi bi-link-45deg"></i></a>
|
<a href="" target="_blank"><i class="bi bi-link-45deg"></i></a>
|
||||||
<label for="toggle_janusxr"><i class="bi bi-info-circle"></i></label>
|
<label for="toggle_janusxr"><i class="bi bi-info-circle"></i></label>
|
||||||
<div class="toggle-box">
|
<div class="toggle-box">
|
||||||
<input type="checkbox" id="toggle_janusxr" hidden>
|
<input type="checkbox" id="toggle_janusxr" hidden>
|
||||||
<div class="hidden-tooltip">
|
<div class="hidden-tooltip">
|
||||||
<i class="bi bi-arrow-90deg-up"></i>
|
<i class="bi bi-arrow-90deg-up"></i>
|
||||||
<small>
|
<small>
|
||||||
This is the JanusXR address.<br>
|
This is the JanusXR address.<br>
|
||||||
<a href="https://janusxr.org/" target="_blank">JanusXR</a> is an Open Immersive Web-layer since 2015, which allows existing webpages to become spatial.<br>
|
<a href="https://janusxr.org/" target="_blank">JanusXR</a> is an Open Immersive Web-layer since 2015, which allows existing webpages to become spatial.<br>
|
||||||
It is Free and Opensource, and allows you to meet others in this experience (avatars, chat and voice etc).<br>
|
It is Free and Opensource, and allows you to meet others in this experience (avatars, chat and voice etc).<br>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
# lets generate a JanusXR spatial layer for the current scene
|
# lets generate a JanusXR spatial layer for the current scene
|
||||||
|
|
@ -117,10 +117,9 @@
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<!-- JML (https://janusxr.org) spatial markup
|
<!-- JML (https://janusxr.org) spatial markup -->
|
||||||
|
|
||||||
<%== jml %>
|
<%== jml %>
|
||||||
-->
|
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue