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 97 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 101 of file materialxgltf/plugin.py.

101 def __init__(self, parent=None):
102 '''
103 @brief Initialize the custom web engine page
104 @param parent: The parent widget
105 '''
106 super().__init__(parent)
107 self.debug = False
108

Member Function Documentation

◆ injectJavaScript()

plugin.glTFEnginePage.injectJavaScript ( self)

Add interestCohort function to the document to disable FLoC.

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

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

◆ javaScriptConsoleMessage()

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

Handle JavaScript console messages.

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

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

◆ load_glb()

plugin.glTFEnginePage.load_glb ( self,
glb_file_path )

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

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

◆ setDebug()

plugin.glTFEnginePage.setDebug ( self,
debug )

Set the debug flag.

Parameters
debugThe debug flag

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

109 def setDebug(self, debug):
110 '''
111 @brief Set the debug flag
112 @param debug: The debug flag
113 '''
114 self.debug = debug
115

Member Data Documentation

◆ debug

bool plugin.glTFEnginePage.debug = False

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


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