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));
327 template <
typename Callback>
330 for (
const auto& property : this->_pClass->properties) {
334 std::forward<Callback>(callback));
339 template <
typename T,
bool Normalized>
351 const Accessor* pAccessor = _pModel->
getSafe<Accessor>(
355 return PropertyAttributePropertyView<T, Normalized>(
359 return PropertyAttributePropertyView<T, Normalized>(
364 template <
typename T,
bool Normalized>
365 PropertyAttributePropertyView<T, Normalized> getPropertyViewImpl(
366 const MeshPrimitive& primitive,
367 const std::string& propertyId,
368 const ClassProperty& classProperty)
const {
369 auto propertyAttributePropertyIter =
370 _pPropertyAttribute->properties.find(propertyId);
371 if (propertyAttributePropertyIter ==
372 _pPropertyAttribute->properties.end()) {
373 if (!classProperty.required && classProperty.defaultProperty) {
377 return getEmptyPropertyViewWithDefault<T, Normalized>(
383 return PropertyAttributePropertyView<T, Normalized>(
387 const PropertyAttributeProperty& propertyAttributeProperty =
388 propertyAttributePropertyIter->second;
390 return createPropertyView<T, Normalized>(
393 propertyAttributeProperty);
396 template <
typename Callback,
bool Normalized>
397 void getScalarPropertyViewImpl(
398 const MeshPrimitive& primitive,
399 const std::string& propertyId,
400 const ClassProperty& classProperty,
402 Callback&& callback)
const {
403 switch (componentType) {
407 getPropertyViewImpl<int8_t, Normalized>(
415 getPropertyViewImpl<uint8_t, Normalized>(
423 getPropertyViewImpl<int16_t, Normalized>(
431 getPropertyViewImpl<uint16_t, Normalized>(
439 getPropertyViewImpl<float, false>(
447 PropertyAttributePropertyView<uint8_t>(
453 template <
typename Callback, glm::length_t N,
bool Normalized>
454 void getVecNPropertyViewImpl(
455 const MeshPrimitive& primitive,
456 const std::string& propertyId,
457 const ClassProperty& classProperty,
459 Callback&& callback)
const {
460 switch (componentType) {
464 getPropertyViewImpl<glm::vec<N, int8_t>, Normalized>(
472 getPropertyViewImpl<glm::vec<N, uint8_t>, Normalized>(
480 getPropertyViewImpl<glm::vec<N, int16_t>, Normalized>(
488 getPropertyViewImpl<glm::vec<N, uint16_t>, Normalized>(
496 getPropertyViewImpl<glm::vec<N, float>,
false>(
504 PropertyAttributePropertyView<uint8_t>(
510 template <
typename Callback,
bool Normalized>
511 void getVecNPropertyViewImpl(
512 const MeshPrimitive& primitive,
513 const std::string& propertyId,
514 const ClassProperty& classProperty,
517 Callback&& callback)
const {
521 getVecNPropertyViewImpl<Callback, 2, Normalized>(
526 std::forward<Callback>(callback));
529 getVecNPropertyViewImpl<Callback, 3, Normalized>(
534 std::forward<Callback>(callback));
537 getVecNPropertyViewImpl<Callback, 4, Normalized>(
542 std::forward<Callback>(callback));
547 PropertyAttributePropertyView<uint8_t>(
553 template <
typename Callback, glm::length_t N,
bool Normalized>
554 void getMatNPropertyViewImpl(
555 const MeshPrimitive& primitive,
556 const std::string& propertyId,
557 const ClassProperty& classProperty,
559 Callback&& callback)
const {
560 switch (componentType) {
564 getPropertyViewImpl<glm::mat<N, N, int8_t>, Normalized>(
572 getPropertyViewImpl<glm::mat<N, N, uint8_t>, Normalized>(
580 getPropertyViewImpl<glm::mat<N, N, int16_t>, Normalized>(
588 getPropertyViewImpl<glm::mat<N, N, uint16_t>, Normalized>(
596 getPropertyViewImpl<glm::mat<N, N, float>,
false>(
604 PropertyAttributePropertyView<uint8_t>(
610 template <
typename Callback,
bool Normalized>
611 void getMatNPropertyViewImpl(
612 const MeshPrimitive& primitive,
613 const std::string& propertyId,
614 const ClassProperty& classProperty,
617 Callback&& callback)
const {
621 getMatNPropertyViewImpl<Callback, 2, Normalized>(
626 std::forward<Callback>(callback));
629 getMatNPropertyViewImpl<Callback, 3, Normalized>(
634 std::forward<Callback>(callback));
637 getMatNPropertyViewImpl<Callback, 4, Normalized>(
642 std::forward<Callback>(callback));
647 PropertyAttributePropertyView<uint8_t>(
653 template <
typename T,
bool Normalized>
654 PropertyAttributePropertyView<T, Normalized> createPropertyView(
655 const MeshPrimitive& primitive,
656 const ClassProperty& classProperty,
657 const PropertyAttributeProperty& propertyAttributeProperty)
const {
660 return PropertyAttributePropertyView<T, Normalized>(
666 classProperty.componentType.value_or(
""));
667 if (TypeToPropertyType<T>::component != componentType) {
668 return PropertyAttributePropertyView<T, Normalized>(
672 if (classProperty.normalized != Normalized) {
673 return PropertyAttributePropertyView<T, Normalized>(
677 if (primitive.attributes.find(propertyAttributeProperty.attribute) ==
678 primitive.attributes.end()) {
679 return PropertyAttributePropertyView<T, Normalized>(
683 const Accessor* pAccessor = _pModel->getSafe<Accessor>(
685 primitive.attributes.at(propertyAttributeProperty.attribute));
687 return PropertyAttributePropertyView<T, Normalized>(
692 return PropertyAttributePropertyView<T, Normalized>(
698 return PropertyAttributePropertyView<T, Normalized>(
699 PropertyAttributePropertyViewStatus::
700 ErrorAccessorComponentTypeMismatch);
703 if (pAccessor->normalized != Normalized) {
704 return PropertyAttributePropertyView<T, Normalized>(
705 PropertyAttributePropertyViewStatus::
706 ErrorAccessorNormalizationMismatch);
709 AccessorView<T> accessorView = AccessorView<T>(*_pModel, *pAccessor);
711 switch (accessorView.status()) {
713 return PropertyAttributePropertyView<T, Normalized>(
716 return PropertyAttributePropertyView<T, Normalized>(
719 return PropertyAttributePropertyView<T, Normalized>(
722 return PropertyAttributePropertyView<T, Normalized>(
725 return PropertyAttributePropertyView<T, Normalized>(
730 return PropertyAttributePropertyView<T, Normalized>(
731 propertyAttributeProperty,
736 const Model* _pModel;
737 const PropertyAttribute* _pPropertyAttribute;
738 const Class* _pClass;