I encountered
Error: this.geometry.morphTargets is undefined
at line 14558
while using this UTF8Loader code:
var loader = new THREE.UTF8Loader();
loader.load("MD/ben-utf8.js", function (geometry) {
callbackModel(geometry, 400, 0xffffff, 0, 0, 0);
}, {scale: 0,offsetX: 0,offsetY: 0,offsetZ: 0});
container.appendChild(renderer.domElement);
window.addEventListener('resize', onWindowResize, false);
}
function callbackModel(geometry, s, color, x, y, z) {
var material = new THREE.MeshLambertMaterial({
color: color,
map: THREE.ImageUtils.loadTexture("MD/text.jpg"),
});
var mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.scale.set(s, s, s);
scene.add(mesh);
}
However, when I switched the loader to BinaryLoader like this:
var loader = new THREE.BinaryLoader();
loader.load("MD/ben-binary.js", function (geometry) {
callbackModel(geometry, 400, 0xffffff, 0, 0, 0);
}, {scale: 0,offsetX: 0,offsetY: 0,offsetZ: 0});
container.appendChild(renderer.domElement);
window.addEventListener('resize', onWindowResize, false);
}
function callbackModel(geometry, s, color, x, y, z) {
var material = new THREE.MeshLambertMaterial({
color: color,
map: THREE.ImageUtils.loadTexture("MD/text.jpg"),
});
var mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.scale.set(s, s, s);
scene.add(mesh);
}
It worked.
I have tried multiple solutions and noticed this issue always occurs when adding material.
What is the fix for this? Is it a bug?
The material in the webgl_loader_utf8.html file is defined as:
object.traverse( function( node ) {
node.castShadow = true;
node.receiveShadow = true;
if ( node.material && ( node.material.name === "head" || node.material.name === "skinbody" ) ) {
node.material.wrapAround = true;
node.material.wrapRGB.set( 0.6, 0.2, 0.1 );
}
} );
I haven't come across this material type before, can someone provide more information about it?
Using Three.js R65.