Skip to content

Commit

Permalink
add check for mesh before setting up texture parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Algorush committed Feb 21, 2024
1 parent 99c6da9 commit b30bc7c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/svg-extruder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b30bc7c

Please sign in to comment.