So I have a glb that I just isnt showing up in the scene no matter where i position it maybe it's the code? (as i've tried glb's i know work with the same code and non appear) here are the relevant code parts:
var loader2 = new GLTFLoader();
loader2.load( 'https://jokertattoo.co.uk/gun.glb', function ( gltfgame ) {
hammer = gltfgame.scene;
gltfgame.scene.traverse( function ( child ) {
if ( child.isMesh ) {
child.frustumCulled = false;
child.castShadow = true;
child.receiveShadow = true;
}
});
hammer.position.y = 120;
scene.add(hammer);
});
and:
function hammerLoaded( geometry ) {
geometry.computeVertexNormals();
geometry.computeFaceNormals();
hammer.position.y = 120;
scene.add(hammer);
var wood = new THREE.MeshPhongMaterial( { color: 0xffffff, map: THREE.ImageUtils.loadTexture( "284-v7.jpg"), shininess: 100, side: THREE.DoubleSide } );
geometry.materials[0] = wood;
var metal = new THREE.MeshPhongMaterial( { color: 0x222222, specular: 0x888888, shininess: 10, metal: true } );
geometry.materials[1] = metal;
var h = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
h.castShadow = true;
h.receiveShadow = false;
var scale = 3.5;
h.scale.set(scale,scale,scale);
h.rotation.x = Math.PI/2;
h.rotation.z = -Math.PI/2;
h.position.y = 12.0;
h.position.z = -26.5;
h.position.x = -6.2;
hammer.add(h);
}
heres a codepen also https://codepen.io/uiunicorn/pen/YzQjJmp
thanks for reading
from glb not showing up in three.js
No comments:
Post a Comment