Consider a “basic” usage of NodeInstantiator: NodeInstantiator {
delegate: Entity { components: [SphereMesh {radius: index / 10}] } } We can use the ‘index’ property in delegate’s properties bindings. Now consider this custom Qt3D Entity (Array.qml, repeats the delegate n times, iteratively applying the specified transform, optionally using an alternate delegate for first and/or last item): import QtQml 2.12 import Qt3D.Core 2.12 import Qt3D.Render 2.12 import Qt3D.Extras 2.12 Entity { id: root property int n: 1 property Transform t: Transform {} default property Component delegate property Component start property Component end NodeInstantiator { id: rep model: root.n delegate: Entity { components: [ Transform { matrix: { var m = Qt.matrix4x4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1) for(var i = 0; i < index; i++) m = m.times(root.t.matrix) return m } } ] NodeInstantiator { delegate: index == 0 && start ? start : index == (rep.model - 1) && end ? root.end : root.delegate } } } } How can this custom Entity provide an ‘index’ property to its delegate? E.g. when used like this: Array { n: 10 t.scale: 0.95 t.translation.y: 0.5 delegate: Entity { components: [ CuboidMesh { property real size: 1.0 xExtent: size; yExtent: size; zExtent: size }, PhongMaterial { diffuse: Qt.rgba(index / 10, 0.5, 0.5, 1.0) shininess: 75 } ] } } but of course in this example it is using a non-existent ‘index’ in the PhongMaterial.diffuse binding. -- Federico Ferri
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest