ModelMesh.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * A model's mesh and its materials.
  3. * <p>
  4. * Use {@link Model#getMesh} to create an instance.
  5. * </p>
  6. *
  7. * @alias ModelMesh
  8. * @internalConstructor
  9. * @class
  10. *
  11. * @see Model#getMesh
  12. */
  13. function ModelMesh(mesh, runtimeMaterialsById, id) {
  14. const materials = [];
  15. const primitives = mesh.primitives;
  16. const length = primitives.length;
  17. for (let i = 0; i < length; ++i) {
  18. const p = primitives[i];
  19. materials[i] = runtimeMaterialsById[p.material];
  20. }
  21. this._name = mesh.name;
  22. this._materials = materials;
  23. this._id = id;
  24. }
  25. Object.defineProperties(ModelMesh.prototype, {
  26. /**
  27. * The value of the <code>name</code> property of this mesh.
  28. *
  29. * @memberof ModelMesh.prototype
  30. *
  31. * @type {String}
  32. * @readonly
  33. */
  34. name: {
  35. get: function () {
  36. return this._name;
  37. },
  38. },
  39. /**
  40. * The index of the mesh.
  41. *
  42. * @memberof ModelMesh.prototype
  43. *
  44. * @type {String}
  45. * @readonly
  46. */
  47. id: {
  48. get: function () {
  49. return this._id;
  50. },
  51. },
  52. /**
  53. * An array of {@link ModelMaterial} instances indexed by the mesh's
  54. * primitive indices.
  55. *
  56. * @memberof ModelMesh.prototype
  57. *
  58. * @type {ModelMaterial[]}
  59. * @readonly
  60. */
  61. materials: {
  62. get: function () {
  63. return this._materials;
  64. },
  65. },
  66. });
  67. export default ModelMesh;