QuiltiX Plugins 0.0.1
Custom Plugins for QuiltiX
Loading...
Searching...
No Matches
plugin.glTFEnginePage Class Reference

Custom web engine page for the glTF viewer. More...

Inheritance diagram for plugin.glTFEnginePage:

Public Member Functions

 __init__ (self, parent=None)
 Initialize the custom web engine page.
 
 setDebug (self, debug)
 Set the debug flag.
 
 javaScriptConsoleMessage (self, level, message, lineNumber, sourceID)
 Handle JavaScript console messages.
 
 injectJavaScript (self)
 Add interestCohort function to the document to disable FLoC.
 
 load_glb (self, glb_file_path)
 

Public Attributes

bool debug = False
 

Detailed Description

Custom web engine page for the glTF viewer.

Definition at line 101 of file materialxgltf/plugin.py.

Constructor & Destructor Documentation

◆ __init__()

plugin.glTFEnginePage.__init__ ( self,
parent = None )

Initialize the custom web engine page.

Parameters
parentThe parent widget

Definition at line 105 of file materialxgltf/plugin.py.

105 def __init__(self, parent=None):
106 '''
107 @brief Initialize the custom web engine page
108 @param parent: The parent widget
109 '''
110 super().__init__(parent)
111 self.debug = False
112

Member Function Documentation

◆ injectJavaScript()

plugin.glTFEnginePage.injectJavaScript ( self)

Add interestCohort function to the document to disable FLoC.

Definition at line 127 of file materialxgltf/plugin.py.

127 def injectJavaScript(self):
128 '''
129 Add interestCohort function to the document to disable FLoC
130 '''
131 script = """
132 document.addEventListener('DOMContentLoaded', (event) => {
133 document.interestCohort = function() { return false; };
134 });
135 """
136 self.runJavaScript(script)
137

◆ javaScriptConsoleMessage()

plugin.glTFEnginePage.javaScriptConsoleMessage ( self,
level,
message,
lineNumber,
sourceID )

Handle JavaScript console messages.

Definition at line 120 of file materialxgltf/plugin.py.

120 def javaScriptConsoleMessage(self, level, message, lineNumber, sourceID):
121 '''
122 @brief Handle JavaScript console messages
123 '''
124 if self.debug:
125 print(f"JS: {message} (line: {lineNumber}, source: {sourceID})")
126

◆ load_glb()

plugin.glTFEnginePage.load_glb ( self,
glb_file_path )

Definition at line 138 of file materialxgltf/plugin.py.

138 def load_glb(self, glb_file_path):
139 # Read the .glb file in binary mode
140 #glb_file_path = "/path/to/your/model.glb" # Change this to your .glb file path
141 if (not os.path.exists(glb_file_path)):
142 print(f"Error: glTF file not found: {glb_file_path}")
143 return
144
145 with open(glb_file_path, "rb") as f:
146 binary_data = f.read()
147
148 # Encode the binary data as Base64
149 base64_data = base64.b64encode(binary_data).decode('utf-8')
150
151 # Run the JavaScript code to store the data in the browser's local storage
152 # Inject the Base64 encoded data into local storage using JavaScript
153 script = f"localStorage.setItem('glbData', '{base64_data}');"
154 self.runJavaScript(script)
155
156 print("GLB data injected into localStorage.")
157
158 self.runJavaScript('loadFromLocalStorage()')
159 print("Update viewer from localStorage.")
160
161

◆ setDebug()

plugin.glTFEnginePage.setDebug ( self,
debug )

Set the debug flag.

Parameters
debugThe debug flag

Definition at line 113 of file materialxgltf/plugin.py.

113 def setDebug(self, debug):
114 '''
115 @brief Set the debug flag
116 @param debug: The debug flag
117 '''
118 self.debug = debug
119

Member Data Documentation

◆ debug

bool plugin.glTFEnginePage.debug = False

Definition at line 111 of file materialxgltf/plugin.py.


The documentation for this class was generated from the following file: