From b30bc7c016ef47507676a060ab2facbf2a9ef614 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Wed, 21 Feb 2024 13:15:58 -0300 Subject: [PATCH] add check for mesh before setting up texture parameters --- src/components/svg-extruder.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/svg-extruder.js b/src/components/svg-extruder.js index f8f6fb0f7..7aeb2a39f 100644 --- a/src/components/svg-extruder.js +++ b/src/components/svg-extruder.js @@ -13,10 +13,13 @@ AFRAME.registerComponent('svg-extruder', { el.addEventListener('materialtextureloaded', () => { // fix texture properties to correctly show texture for extruded mesh - const texture = el.getObject3D('mesh').material.map; - texture.wraps = texture.wrapt = THREE.repeatwrapping; - texture.repeat.set( 1 / 100, 1 / 100 ); - texture.offset.set( 0.1, 0.5 ); + const extrudedMesh = el.getObject3D('mesh'); + if (extrudedMesh && extrudedMesh.material) { + const texture = extrudedMesh.material.map; + texture.wraps = texture.wrapt = THREE.repeatwrapping; + texture.repeat.set( 1 / 100, 1 / 100 ); + texture.offset.set( 0.1, 0.5 ); + } }); if (svgString) {