Skip to content

Commit 2665662

Browse files
Update multiple mobile viewers
1 parent 5af8361 commit 2665662

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

viewers/templates/Mobile/MOBJ Viewer.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,14 @@
783783
child.material.forEach( mtrl => {
784784
set_texture_colorSpace( mtrl );
785785

786+
if ((mtrl.aoMap || mtrl.lightMap) && child.geometry.attributes.uv1 === undefined &&
787+
child.geometry.attributes.uv !== undefined) {
788+
789+
child.geometry.setAttribute( 'uv1', child.geometry.attributes.uv );
790+
if (mtrl.aoMap) mtrl.aoMap.channel = 1;
791+
if (mtrl.lightMap) mtrl.lightMap.channel = 1;
792+
}
793+
786794
mtrl.castShadow = true;
787795
mtrl.receiveShadow = true;
788796
mtrl.vertexColors = vertex_colors_enabled;
@@ -794,6 +802,14 @@
794802
} else {
795803
set_texture_colorSpace( child.material );
796804

805+
if ((child.material.aoMap || child.material.lightMap) && child.geometry.attributes.uv1 === undefined &&
806+
child.geometry.attributes.uv !== undefined) {
807+
808+
child.geometry.setAttribute( 'uv1', child.geometry.attributes.uv );
809+
if (child.material.aoMap) child.material.aoMap.channel = 1;
810+
if (child.material.lightMap) child.material.lightMap.channel = 1;
811+
}
812+
797813
child.material.castShadow = true;
798814
child.material.receiveShadow = true;
799815
child.material.vertexColors = vertex_colors_enabled;

viewers/templates/Mobile/MOBJ WebGPU.html

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,26 +2120,32 @@
21202120

21212121
if (Array.isArray( child.material )) {
21222122
child.material.forEach( mtrl => {
2123-
if (mtrl.aoMap && child.geometry.attributes.uv1 === undefined && child.geometry.attributes.uv !== undefined) {
2123+
set_texture_colorSpace( mtrl );
2124+
2125+
if ((mtrl.aoMap || mtrl.lightMap) && child.geometry.attributes.uv1 === undefined &&
2126+
child.geometry.attributes.uv !== undefined) {
2127+
21242128
child.geometry.setAttribute( 'uv1', child.geometry.attributes.uv );
2125-
mtrl.aoMap.channel = 1;
2129+
if (mtrl.aoMap) mtrl.aoMap.channel = 1;
2130+
if (mtrl.lightMap) mtrl.lightMap.channel = 1;
21262131
}
21272132

2128-
set_texture_colorSpace( mtrl );
2129-
21302133
mtrl.vertexColors = child.geometry.hasAttribute( 'color' );
21312134
if (child.isPoints) mtrl.size = isMobile === true ? 0.8 : 1.25;
21322135

21332136
mtrl.needsUpdate = true;
21342137
});
21352138
} else {
2136-
if (child.material.aoMap && child.geometry.attributes.uv1 === undefined && child.geometry.attributes.uv !== undefined) {
2139+
set_texture_colorSpace( child.material );
2140+
2141+
if ((child.material.aoMap || child.material.lightMap) && child.geometry.attributes.uv1 === undefined &&
2142+
child.geometry.attributes.uv !== undefined) {
2143+
21372144
child.geometry.setAttribute( 'uv1', child.geometry.attributes.uv );
2138-
child.material.aoMap.channel = 1;
2145+
if (child.material.aoMap) child.material.aoMap.channel = 1;
2146+
if (child.material.lightMap) child.material.lightMap.channel = 1;
21392147
}
21402148

2141-
set_texture_colorSpace( child.material );
2142-
21432149
child.material.vertexColors = child.geometry.hasAttribute( 'color' );
21442150
if (child.isPoints) child.material.size = isMobile === true ? 0.8 : 1.25;
21452151

0 commit comments

Comments
 (0)