<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QtQuick3D - Colorize model imported from .obj file by the Runtimeloader]]></title><description><![CDATA[<p dir="auto">Hello Folks!<br />
I was upgrading to Qt 6.8/QML and tried to load my .obj - File with QML Syntax.<br />
The Mesh gets loaded, positioned and scaled properly, but it is white.<br />
I need to apply custom colors to the meshes.</p>
<p dir="auto">This is how i got so far: NOTE: This is not working. Any approach to colorize the Model fails:</p>
<pre><code>      RuntimeLoader {
           id: loader
           source: "Resources/fem_3.obj"
           position: Qt.vector3d(0,1,0)
           scale: Qt.vector3d(5,5,5)

           function applyMaterialToAllModels(node, material) {

               if (typeof node === "undefined") return;

               if (node instanceof Model) {
                   node.material = material;
               } else {
                   // console.log("node type: " + typeof node);
               }
               if (typeof node.children === "undefined") return;
               for (var i = 0; i &lt; node.children.length; i++) {
                   applyMaterialToAllModels(node.children[i], material)
               }
           }

            onStatusChanged:  {

                if (loader.status === RuntimeLoader.Success)
                {
                    console.log("success loading asset file.")

                    var material3 = Qt.createQmlObject( "import QtQuick3D\n" +
                      "DefaultMaterial {\n" +
                       " diffuseColor: \"red\"\n" +
                       "}", loader);
                    material3.diffuseColor = "red";

                    applyMaterialToAllModels(loader, material3);
                }
            }
        }
</code></pre>
<p dir="auto">Can you help me to apply a color?</p>
<p dir="auto">best regards, kevin_d</p>
]]></description><link>https://forum.qt.io/topic/165063/qtquick3d-colorize-model-imported-from-.obj-file-by-the-runtimeloader</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 09:40:10 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/165063.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 06 Sep 2026 10:09:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QtQuick3D - Colorize model imported from .obj file by the Runtimeloader on Sun, 06 Sep 2026 21:06:39 GMT]]></title><description><![CDATA[<p dir="auto">Change <code>node.material = material;</code> to <code>node.materials = [material];</code>  because the Model in QtQuick3D has a property called <code>materials</code> (a list), not a single <code>material</code>.</p>
]]></description><link>https://forum.qt.io/post/840016</link><guid isPermaLink="true">https://forum.qt.io/post/840016</guid><dc:creator><![CDATA[Nils Sjoberg]]></dc:creator><pubDate>Sun, 06 Sep 2026 21:06:39 GMT</pubDate></item></channel></rss>