Skip to content

Commit 5273834

Browse files
committed
BugFix: FBX loader => Model with transparent texture
1 parent 3578884 commit 5273834

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/components/ChangeTexture.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ const ChangeTexture = () => {
1212
} = useContext(ModalContext);
1313

1414
useEffect(() => {
15+
console.log(mainModel);
1516
if (mainModel) {
1617
mainModel.traverse((child) => {
17-
if (child.isMesh) {
18+
if (child.isMesh && typeof child.material.map !== "function") {
1819
setTexture(child.material.map);
1920
setDefaultTexture(child.material.map);
2021
}
@@ -25,7 +26,7 @@ const ChangeTexture = () => {
2526
useEffect(() => {
2627
if (texture !== null) {
2728
mainModel.traverse((child) => {
28-
if (child.isMesh) {
29+
if (child.isMesh && typeof child.material.map !== "function") {
2930
child.material.map = texture;
3031
child.material.needsUpdate = true;
3132
}

src/helpers/loadModel.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader.js";
22
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
3-
import { Box3, Mesh, Vector3 } from "three";
3+
import { Box3, Vector3 } from "three";
44

55
export default (path, type, callback) => {
66
let loader = null;
@@ -15,11 +15,6 @@ export default (path, type, callback) => {
1515
child.castShadow = true;
1616
child.receiveShadow = true;
1717
}
18-
// if (child instanceof Mesh) {
19-
// // apply texture
20-
// child.material.map = undefined;
21-
// child.material.needsUpdate = true;
22-
// }
2318
});
2419

2520
var box = new Box3().setFromObject(object);

0 commit comments

Comments
 (0)