diff --git a/libraries/graphics-scripting/src/graphics-scripting/Forward.h b/libraries/graphics-scripting/src/graphics-scripting/Forward.h index ed8e96a12f..104674eddc 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/Forward.h +++ b/libraries/graphics-scripting/src/graphics-scripting/Forward.h @@ -36,6 +36,30 @@ namespace scriptable { using ModelProviderPointer = std::shared_ptr; using WeakModelProviderPointer = std::weak_ptr; + /**jsdoc + * @typedef {object} Graphics.Material + * @property {string} name + * @property {string} model + * @property {number} opacity + * @property {number} roughness + * @property {number} metallic + * @property {number} scattering + * @property {boolean} unlit + * @propety {Vec3} emissive + * @propety {Vec3} albedo + * @property {string} emissiveMap + * @property {string} albedoMap + * @property {string} opacityMap + * @property {string} metallicMap + * @property {string} specularMap + * @property {string} roughnessMap + * @property {string} glossMap + * @property {string} normalMap + * @property {string} bumpMap + * @property {string} occlusionMap + * @property {string} lightmapMap + * @property {string} scatteringMap + */ class ScriptableMaterial { public: ScriptableMaterial() {} @@ -68,7 +92,7 @@ namespace scriptable { /**jsdoc * @typedef {object} Graphics.MaterialLayer - * @property {Material} material - This layer's material. + * @property {Graphics.Material} material - This layer's material. * @property {number} priority - The priority of this layer. If multiple materials are applied to a mesh part, only the highest priority layer is used. */ class ScriptableMaterialLayer { diff --git a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp index 20b54b02c9..6fd0017ae2 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp +++ b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp @@ -166,6 +166,17 @@ bool GraphicsScriptingInterface::updateMeshPart(scriptable::ScriptableMeshPointe scriptable::ScriptableMeshPointer GraphicsScriptingInterface::newMesh(const QVariantMap& ifsMeshData) { // TODO: this is bare-bones way for now to improvise a new mesh from the scripting side // in the future we want to support a formal C++ structure data type here instead + + /**jsdoc + * @typedef {object} Graphics.IFSData + * @property {string} [name=""] - mesh name (useful for debugging / debug prints). + * @property {string} [topology=""] + * @property {number[]} indices - vertex indices to use for the mesh faces. + * @property {Vec3[]} vertices - vertex positions (model space) + * @property {Vec3[]} [normals=[]] - vertex normals (normalized) + * @property {Vec3[]} [colors=[]] - vertex colors (normalized) + * @property {Vec2[]} [texCoords0=[]] - vertex texture coordinates (normalized) + */ QString meshName = ifsMeshData.value("name").toString(); QString topologyName = ifsMeshData.value("topology").toString(); QVector indices = buffer_helpers::variantToVector(ifsMeshData.value("indices")); diff --git a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h index b88c6345cf..1ec60c4244 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h +++ b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h @@ -46,10 +46,28 @@ public slots: */ scriptable::ScriptableModelPointer getModel(QUuid uuid); + /**jsdoc + * @function Graphics.updateModel + * @param {Uuid} id + * @param {Graphics.Model} model + * @returns {boolean} + */ bool updateModel(QUuid uuid, const scriptable::ScriptableModelPointer& model); + /**jsdoc + * @function Graphics.canUpdateModel + * @param {Uuid} id + * @param {number} [meshIndex=-1] + * @param {number} [partNumber=-1] + * @returns {boolean} + */ bool canUpdateModel(QUuid uuid, int meshIndex = -1, int partNumber = -1); + /**jsdoc + * @function Graphics.newModel + * @param {Graphics.Mesh[]} meshes + * @returns {Graphics.Model} + */ scriptable::ScriptableModelPointer newModel(const scriptable::ScriptableMeshes& meshes); /**jsdoc @@ -59,15 +77,6 @@ public slots: * @param {Graphics.IFSData} ifsMeshData Index-Faced Set (IFS) arrays used to create the new mesh. * @returns {Graphics.Mesh} the resulting Mesh / Mesh Part object */ - /**jsdoc - * @typedef {object} Graphics.IFSData - * @property {string} [name] - mesh name (useful for debugging / debug prints). - * @property {number[]} indices - vertex indices to use for the mesh faces. - * @property {Vec3[]} vertices - vertex positions (model space) - * @property {Vec3[]} [normals] - vertex normals (normalized) - * @property {Vec3[]} [colors] - vertex colors (normalized) - * @property {Vec2[]} [texCoords0] - vertex texture coordinates (normalized) - */ scriptable::ScriptableMeshPointer newMesh(const QVariantMap& ifsMeshData); #ifdef SCRIPTABLE_MESH_TODO @@ -77,6 +86,11 @@ public slots: bool updateMeshPart(scriptable::ScriptableMeshPointer mesh, scriptable::ScriptableMeshPartPointer part); #endif + /**jsdoc + * @function Graphics.exportModelToOBJ + * @param {Graphics.Model} model + * @returns {string} + */ QString exportModelToOBJ(const scriptable::ScriptableModel& in); private: diff --git a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.h b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.h index 62a67aa5e6..dcb1c53759 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.h +++ b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.h @@ -36,6 +36,10 @@ namespace scriptable { * @property {number} numIndices - Total number of vertex indices in the mesh. * @property {number} numVertices - Total number of vertices in the Mesh. * @property {number} numAttributes - Number of currently defined vertex attributes. + * @property {boolean} valid + * @property {boolean} strong + * @property {object} extents + * @property {object} bufferFormats */ class ScriptableMesh : public ScriptableMeshBase, QScriptable { Q_OBJECT diff --git a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMeshPart.h b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMeshPart.h index dd71d9b998..7352fcd0f6 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMeshPart.h +++ b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMeshPart.h @@ -12,7 +12,11 @@ namespace scriptable { /**jsdoc * @typedef {object} Graphics.MeshPart + * @property {boolean} valid * @property {number} partIndex - The part index (within the containing Mesh). + * @property {number} firstVertexIndex + * @property {number} baseVertexIndex + * @property {number} lastVertexIndex * @property {Graphics.Topology} topology - element interpretation (currently only 'triangles' is supported). * @property {string[]} attributeNames - Vertex attribute names (color, normal, etc.) * @property {number} numIndices - Number of vertex indices that this mesh part refers to. @@ -20,6 +24,8 @@ namespace scriptable { * @property {number} numFaces - Number of faces represented by the mesh part (numIndices / numVerticesPerFace). * @property {number} numVertices - Total number of vertices in the containing Mesh. * @property {number} numAttributes - Number of currently defined vertex attributes. + * @property {object} extents + * @property {object} bufferFormats */ class ScriptableMeshPart : public QObject, QScriptable { diff --git a/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.h b/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.h index ac0b7b9623..7d1ca5f560 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.h +++ b/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.h @@ -21,7 +21,7 @@ namespace scriptable { * @property {Uuid} objectID - UUID of corresponding inworld object (if model is associated) * @property {number} numMeshes - The number of submeshes contained in the model. * @property {Graphics.Mesh[]} meshes - Array of submesh references. - * @property {Object.} materialLayers - Map of materials layer lists. You can look up a material layer list by mesh part number or by material name. + * @property {Object.} materialLayers - Map of materials layer lists. You can look up a material layer list by mesh part number or by material name. * @property {string[]} materialNames - Array of all the material names used by the mesh parts of this model, in order (e.g. materialNames[0] is the name of the first mesh part's material). */ diff --git a/libraries/graphics/src/graphics/Geometry.h b/libraries/graphics/src/graphics/Geometry.h index 485542d26b..eddfdbd1b6 100755 --- a/libraries/graphics/src/graphics/Geometry.h +++ b/libraries/graphics/src/graphics/Geometry.h @@ -76,6 +76,23 @@ public: // Access vertex position value const Vec3& getPos(Index index) const { return _vertexBuffer.get(index); } + /**jsdoc + * + * + * + * + * + * + * + * + * + * + * + * + * + *
ValueDescription
0Points.
1Lines.
2Line strip.
3Triangles.
4Triangle strip.
5Quads.
6Quad strip.
+ * @typedef {number} Graphics.Topology + */ enum Topology { POINTS = 0, LINES, diff --git a/tools/jsdoc/plugins/hifi.js b/tools/jsdoc/plugins/hifi.js index de53f52f32..8606007b89 100644 --- a/tools/jsdoc/plugins/hifi.js +++ b/tools/jsdoc/plugins/hifi.js @@ -44,6 +44,7 @@ exports.handlers = { '../../libraries/controllers/src/controllers/impl/', '../../libraries/display-plugins/src/display-plugins/', '../../libraries/entities/src', + '../../libraries/graphics/src/graphics/', '../../libraries/graphics-scripting/src/graphics-scripting/', '../../libraries/input-plugins/src/input-plugins', '../../libraries/model-networking/src/model-networking/',