wireframe works now, was traversing scene instead of object

This commit is contained in:
CJSatnarine
2025-03-03 12:12:56 -05:00
parent 04b036dbc9
commit 90dd7fc1d6
3 changed files with 42 additions and 23 deletions

File diff suppressed because one or more lines are too long

2
dist/index.html vendored
View File

@@ -11,7 +11,7 @@
} }
</style> </style>
<script type="module" crossorigin src="/assets/index-C_ucNTj8.js"></script> <script type="module" crossorigin src="/assets/index-BvvhR7ed.js"></script>
</head> </head>
<body> <body>

33
main.js
View File

@@ -25,13 +25,13 @@ objectLoader.load(
function(object) { function(object) {
console.log(object); console.log(object);
scene.traverse((object) => { object.traverse((child) => {
if (object instanceof THREE.Mesh) { // Apparently instanceof is a curse.
if (child instanceof THREE.Mesh) {
console.log(child.geometry);
console.log('is instance of mesh'); console.log('is instance of mesh');
object.material = new THREE.MeshStandardMaterial({color: 0x962FFE}); child.material = new THREE.MeshStandardMaterial({color: 0x962FFE});
object.material.wireframe = true; child.material.wireframe = true;
} else {
console.log('not instance of mesh');
} }
}); });
@@ -41,10 +41,29 @@ objectLoader.load(
console.log((xhr.loaded / xhr.total * 100) + '% loaded'); console.log((xhr.loaded / xhr.total * 100) + '% loaded');
}, },
function(error) { function(error) {
console.log('an error happened'); console.log('an error happened', error);
} }
); );
function animate() { function animate() {
renderer.render(scene, camera); renderer.render(scene, camera);
} }