Files
P42_UI/app/assets/brol/mecha.js
T

40 lines
1.7 KiB
JavaScript

//////////////TESTING /////////////////
this.threeClock = new THREE.Clock()
const loader = new GLTFLoader().setPath( '/app/assets/3dModels/' );
loader.load( 'mechdrone/scene.gltf', async function ( gltf ) {
const model = gltf.scene;
// wait until the model can be added to the scene without blocking due to shader compilation
await this.renderer.compileAsync( model, this.camera, this.scene );
model.scale.set(5,5,5)
this.scene.add( model )
model.traverse(obj => {
console.log(
obj.type,
obj.name || '(no name)',
obj.isBone ? '[BONE]' : ''
)
if (obj.isMesh && obj.material && obj.material.color) {
const c = obj.material.color.clone()
const boost = 0.1 // réglage global
obj.material.emissive = c
obj.material.emissiveIntensity = boost
}
})
this.leftArm = model.getObjectByName('ArmL1_01')
if (gltf.animations && gltf.animations.length > 0) {
this.mixer = new THREE.AnimationMixer(gltf.scene)
// On joue la première animation
const action = this.mixer.clipAction(gltf.animations[0])
action.play()
}
}.bind(this) )
// In Render:
const delta = this.threeClock.getDelta()
if(this.mixer) this.mixer.update(delta)