Compare commits
2 commits
34f6e052da
...
ac0e1aeb0e
| Author | SHA1 | Date | |
|---|---|---|---|
| ac0e1aeb0e | |||
| 5e0bfbf799 |
4 changed files with 53 additions and 31 deletions
19
manyfold/root/hook.d/inotify_MODIFY/create_yaml.sh
Normal file
19
manyfold/root/hook.d/inotify_MODIFY/create_yaml.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
echo "$1" | grep datapackage || exit 0 # nothing to do
|
||||
dir=$(dirname $1)
|
||||
cd "$dir"
|
||||
|
||||
test -f xrforge.yml || exit 0 # nothing to do
|
||||
|
||||
echo '--- # xrforge yaml v0.1
|
||||
scene:
|
||||
version: 1.0
|
||||
xrf:
|
||||
links: yes # add links from datapackage.json#/links [rezstyle fontmap / ruler]
|
||||
sidecar_json: yes # add links from <experience>.json sidecar-file (https://xrfragment.org)
|
||||
|
||||
texture:
|
||||
export: yes # extract textures from uploaded 3D file
|
||||
import: yes # import uploaded texture to 3D file (when name matches)
|
||||
|
||||
' > xrforge.yaml
|
||||
|
|
@ -1,34 +1,14 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'json'
|
||||
|
||||
extensions = ['.glb', '.gltf', '.blend', '.usdz', '.obj', '.dae']
|
||||
require_relative './../../xrforge.rb'
|
||||
|
||||
# Check if a filename is provided
|
||||
if ARGV.length != 1
|
||||
puts "Usage: #{$0} <filename>"
|
||||
puts "Usage: #{$0} <path/to/datapackage.json>"
|
||||
exit 1
|
||||
end
|
||||
|
||||
def log_message(message, filename, reset = false)
|
||||
|
||||
# Empty the log file if reset is true
|
||||
if reset
|
||||
File.open(filename, 'w') do |file|
|
||||
timestamp = Time.now.strftime('%Y-%m-%d %H:%M')
|
||||
file.write("#{timestamp}\n\n")
|
||||
end
|
||||
end
|
||||
|
||||
# Create the full log entry
|
||||
|
||||
# Append the log entry to the log file
|
||||
File.open(filename, 'a') do |file|
|
||||
file.write("#{message}\n")
|
||||
end
|
||||
puts("#{message}\n")
|
||||
end
|
||||
|
||||
filename = ARGV[0]
|
||||
|
||||
begin
|
||||
|
|
@ -37,11 +17,11 @@ begin
|
|||
|
||||
logfile = File.join( File.dirname(filename), "xrfragment.txt" )
|
||||
|
||||
log_message("✔ starting XR fragments check", logfile, true)
|
||||
log("✅ starting XR fragments check", logfile, true)
|
||||
|
||||
# Extract the desired field (assuming the field is named 'model_file')
|
||||
thumb_file = data['image']
|
||||
log_message("✔ thumbnail sidecar-file '#{thumb_file}' detected", logfile)
|
||||
log("✅ thumbnail sidecar-file '#{thumb_file}' detected", logfile)
|
||||
|
||||
# Get the base name of the thumbnail file without its extension
|
||||
base_name = File.basename(thumb_file, File.extname(thumb_file))
|
||||
|
|
@ -49,26 +29,26 @@ begin
|
|||
model_file = nil # Initialize model_file to nil
|
||||
|
||||
# Loop over the list of extensions
|
||||
extensions.each do |ext|
|
||||
Xrforge.model_extensions.each do |ext|
|
||||
# Construct the filename with the current extension
|
||||
filename = "#{base_name}#{ext}"
|
||||
|
||||
# Check if the file exists
|
||||
if File.exist?(filename)
|
||||
log_message("✔ 3D file '#{filename}' detected", logfile)
|
||||
log("✅ 3D file '#{filename}' detected", logfile)
|
||||
model_file = filename # Store the found filename
|
||||
break # Stop the loop once a file is found
|
||||
else
|
||||
# Log a message for the file that was not found, but don't stop
|
||||
log_message("⚠️ 3D file '#{filename}' not detected", logfile)
|
||||
log("⚠️ 3D file '#{filename}' not detected", logfile)
|
||||
end
|
||||
end
|
||||
|
||||
# Check if a model file was found after the loop
|
||||
if model_file
|
||||
log_message("✅ Final model file: '#{model_file}'", logfile)
|
||||
log("✅ Final model file: '#{model_file}'", logfile)
|
||||
else
|
||||
log_message("❌ No suitable 3D file found for XR Fragments-compatible experience", logfile)
|
||||
log("❌ No suitable 3D file found for XR Fragments-compatible experience", logfile)
|
||||
end
|
||||
|
||||
# Construct the output filename
|
||||
|
|
@ -87,4 +67,4 @@ rescue => e
|
|||
end
|
||||
|
||||
|
||||
log_message("", logfile)
|
||||
log("", logfile)
|
||||
|
|
|
|||
23
manyfold/root/xrforge.rb
Normal file
23
manyfold/root/xrforge.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Module xrforge
|
||||
|
||||
model_extensions = ['.glb', '.gltf', '.blend', '.usdz', '.obj', '.dae']
|
||||
|
||||
def log(message, filename, reset = false)
|
||||
|
||||
# Empty the log file if reset is true
|
||||
if reset
|
||||
File.open(filename, 'w') do |file|
|
||||
timestamp = Time.now.strftime('%Y-%m-%d %H:%M')
|
||||
file.write("#{timestamp}\n\n")
|
||||
end
|
||||
end
|
||||
|
||||
# Create the full log entry
|
||||
|
||||
# Append the log entry to the log file
|
||||
File.open(filename, 'a') do |file|
|
||||
file.write("#{message}\n")
|
||||
end
|
||||
puts("#{message}\n")
|
||||
end
|
||||
end
|
||||
|
|
@ -112,7 +112,7 @@ class Components::ModelCard < Components::Base
|
|||
end
|
||||
div class: "col col-auto" do
|
||||
BurgerMenu do
|
||||
DropdownItem(icon: "app", label: "Open in Godot Web" , path: "/godot/?url="+"/"+@model.library.name+"/"+@model.path.gsub("#","%23")+"/package_godot.zip", aria_label: translate("components.model_card.edit_button.label", name: @model.name), target: "_blank" )
|
||||
#DropdownItem(icon: "app", label: "Open in Godot Web" , path: "/godot/?url="+"/"+@model.library.name+"/"+@model.path.gsub("#","%23")+"/package_godot.zip", aria_label: translate("components.model_card.edit_button.label", name: @model.name), target: "_blank" )
|
||||
DropdownItem(icon: "pencil", label: t("components.model_card.edit_button.text"), path: model_path(@model), aria_label: translate("components.model_card.edit_button.label", name: @model.name))
|
||||
|
||||
DropdownItem(icon: "trash", label: t("components.model_card.delete_button.text"), path: model_path(@model), method: :delete, aria_label: translate("components.model_card.delete_button.label", name: @model.name), confirm: translate("models.destroy.confirm")) if policy(@model).destroy?
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue