From d91d6a9daf1da4c8be9ee0aee11bcb7420388c21 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Mon, 12 Sep 2022 07:53:31 -0400 Subject: [PATCH] Fixed visualize rooms with no sensor showing up black before texture is loaded --- js/component/scene.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/js/component/scene.js b/js/component/scene.js index fc4e313..9fdbd71 100644 --- a/js/component/scene.js +++ b/js/component/scene.js @@ -550,20 +550,21 @@ beestat.component.scene.prototype.add_room_ = function(layer, group, room) { extrude_settings ); - let material; + const material = new THREE.MeshPhongMaterial({ + 'color': color + }); if (room.sensor_id === undefined) { - const texture = new THREE.TextureLoader().load('img/visualize/stripe.png'); - texture.wrapS = THREE.RepeatWrapping; - texture.wrapT = THREE.RepeatWrapping; - texture.repeat.set(0.005, 0.005); - - material = new THREE.MeshPhongMaterial({ - 'map': texture - }); - } else { - material = new THREE.MeshPhongMaterial({ - 'color': color - }); + const loader = new THREE.TextureLoader(); + loader.load( + 'img/visualize/stripe.png', + function(texture) { + texture.wrapS = THREE.RepeatWrapping; + texture.wrapT = THREE.RepeatWrapping; + texture.repeat.set(0.005, 0.005); + material.map = texture; + material.needsUpdate = true; + } + ); } const mesh = new THREE.Mesh(geometry, material);