97 const std::optional<std::string>&
name() const noexcept {
98 return _pPropertyAttribute->
name;
143 template <
typename T,
bool Normalized = false>
146 const std::string& propertyId)
const {
152 if (!pClassProperty) {
164 return getPropertyViewImpl<T, Normalized>(
191 template <
typename Callback>
194 const std::string& propertyId,
195 Callback&& callback)
const {
201 ErrorInvalidPropertyAttribute));
206 if (!pClassProperty) {
214 if (pClassProperty->
array) {
240 getScalarPropertyViewImpl<Callback, true>(
245 std::forward<Callback>(callback));
247 getScalarPropertyViewImpl<Callback, false>(
252 std::forward<Callback>(callback));
259 getVecNPropertyViewImpl<Callback, true>(
265 std::forward<Callback>(callback));
267 getVecNPropertyViewImpl<Callback, false>(
273 std::forward<Callback>(callback));
280 getMatNPropertyViewImpl<Callback, true>(
286 std::forward<Callback>(callback));
288 getMatNPropertyViewImpl<Callback, false>(
294 std::forward<Callback>(callback));
326 template <
typename Callback>
329 for (
const auto& property : this->_pClass->
properties) {
333 std::forward<Callback>(callback));
338 template <
typename T,
bool Normalized>
350 const Accessor* pAccessor = _pModel->
getSafe<Accessor>(
354 return PropertyAttributePropertyView<T, Normalized>(
358 return PropertyAttributePropertyView<T, Normalized>(
363 template <
typename T,
bool Normalized>
364 PropertyAttributePropertyView<T, Normalized> getPropertyViewImpl(
365 const MeshPrimitive& primitive,
366 const std::string& propertyId,
367 const ClassProperty& classProperty)
const {
368 auto propertyAttributePropertyIter =
369 _pPropertyAttribute->
properties.find(propertyId);
370 if (propertyAttributePropertyIter ==
372 if (!classProperty.required && classProperty.defaultProperty) {
376 return getEmptyPropertyViewWithDefault<T, Normalized>(
382 return PropertyAttributePropertyView<T, Normalized>(
386 const PropertyAttributeProperty& propertyAttributeProperty =
387 propertyAttributePropertyIter->second;
389 return createPropertyView<T, Normalized>(
392 propertyAttributeProperty);
395 template <
typename Callback,
bool Normalized>
396 void getScalarPropertyViewImpl(
397 const MeshPrimitive& primitive,
398 const std::string& propertyId,
399 const ClassProperty& classProperty,
401 Callback&& callback)
const {
402 switch (componentType) {
406 getPropertyViewImpl<int8_t, Normalized>(
414 getPropertyViewImpl<uint8_t, Normalized>(
422 getPropertyViewImpl<int16_t, Normalized>(
430 getPropertyViewImpl<uint16_t, Normalized>(
438 getPropertyViewImpl<float, false>(
446 PropertyAttributePropertyView<uint8_t>(
452 template <
typename Callback, glm::length_t N,
bool Normalized>
453 void getVecNPropertyViewImpl(
454 const MeshPrimitive& primitive,
455 const std::string& propertyId,
456 const ClassProperty& classProperty,
458 Callback&& callback)
const {
459 switch (componentType) {
463 getPropertyViewImpl<glm::vec<N, int8_t>, Normalized>(
471 getPropertyViewImpl<glm::vec<N, uint8_t>, Normalized>(
479 getPropertyViewImpl<glm::vec<N, int16_t>, Normalized>(
487 getPropertyViewImpl<glm::vec<N, uint16_t>, Normalized>(
495 getPropertyViewImpl<glm::vec<N, float>,
false>(
503 PropertyAttributePropertyView<uint8_t>(
509 template <
typename Callback,
bool Normalized>
510 void getVecNPropertyViewImpl(
511 const MeshPrimitive& primitive,
512 const std::string& propertyId,
513 const ClassProperty& classProperty,
516 Callback&& callback)
const {
520 getVecNPropertyViewImpl<Callback, 2, Normalized>(
525 std::forward<Callback>(callback));
528 getVecNPropertyViewImpl<Callback, 3, Normalized>(
533 std::forward<Callback>(callback));
536 getVecNPropertyViewImpl<Callback, 4, Normalized>(
541 std::forward<Callback>(callback));
546 PropertyAttributePropertyView<uint8_t>(
552 template <
typename Callback, glm::length_t N,
bool Normalized>
553 void getMatNPropertyViewImpl(
554 const MeshPrimitive& primitive,
555 const std::string& propertyId,
556 const ClassProperty& classProperty,
558 Callback&& callback)
const {
559 switch (componentType) {
563 getPropertyViewImpl<glm::mat<N, N, int8_t>, Normalized>(
571 getPropertyViewImpl<glm::mat<N, N, uint8_t>, Normalized>(
579 getPropertyViewImpl<glm::mat<N, N, int16_t>, Normalized>(
587 getPropertyViewImpl<glm::mat<N, N, uint16_t>, Normalized>(
595 getPropertyViewImpl<glm::mat<N, N, float>,
false>(
603 PropertyAttributePropertyView<uint8_t>(
609 template <
typename Callback,
bool Normalized>
610 void getMatNPropertyViewImpl(
611 const MeshPrimitive& primitive,
612 const std::string& propertyId,
613 const ClassProperty& classProperty,
616 Callback&& callback)
const {
620 getMatNPropertyViewImpl<Callback, 2, Normalized>(
625 std::forward<Callback>(callback));
628 getMatNPropertyViewImpl<Callback, 3, Normalized>(
633 std::forward<Callback>(callback));
636 getMatNPropertyViewImpl<Callback, 4, Normalized>(
641 std::forward<Callback>(callback));
646 PropertyAttributePropertyView<uint8_t>(
652 template <
typename T,
bool Normalized>
653 PropertyAttributePropertyView<T, Normalized> createPropertyView(
654 const MeshPrimitive& primitive,
655 const ClassProperty& classProperty,
656 const PropertyAttributeProperty& propertyAttributeProperty)
const {
658 if (TypeToPropertyType<T>::value != type) {
659 return PropertyAttributePropertyView<T, Normalized>(
665 classProperty.componentType.value_or(
""));
666 if (TypeToPropertyType<T>::component != componentType) {
667 return PropertyAttributePropertyView<T, Normalized>(
671 if (classProperty.normalized != Normalized) {
672 return PropertyAttributePropertyView<T, Normalized>(
676 if (primitive.attributes.find(propertyAttributeProperty.attribute) ==
677 primitive.attributes.end()) {
678 return PropertyAttributePropertyView<T, Normalized>(
682 const Accessor* pAccessor = _pModel->
getSafe<Accessor>(
684 primitive.attributes.at(propertyAttributeProperty.attribute));
686 return PropertyAttributePropertyView<T, Normalized>(
691 return PropertyAttributePropertyView<T, Normalized>(
697 return PropertyAttributePropertyView<T, Normalized>(
698 PropertyAttributePropertyViewStatus::
699 ErrorAccessorComponentTypeMismatch);
702 if (pAccessor->normalized != Normalized) {
703 return PropertyAttributePropertyView<T, Normalized>(
704 PropertyAttributePropertyViewStatus::
705 ErrorAccessorNormalizationMismatch);
708 AccessorView<T> accessorView = AccessorView<T>(*_pModel, *pAccessor);
710 switch (accessorView.status()) {
712 return PropertyAttributePropertyView<T, Normalized>(
715 return PropertyAttributePropertyView<T, Normalized>(
718 return PropertyAttributePropertyView<T, Normalized>(
721 return PropertyAttributePropertyView<T, Normalized>(
724 return PropertyAttributePropertyView<T, Normalized>(
729 return PropertyAttributePropertyView<T, Normalized>(
730 propertyAttributeProperty,
735 const Model* _pModel;
736 const PropertyAttribute* _pPropertyAttribute;
737 const Class* _pClass;