let model = null
var children =
/**
- Model
*/
gltfLoader.load(
‘/resources/datacemetry.glb’,
(gltf) =>
{
model = gltf.scene
model.position.y=-19
gltf.scene.traverse(function(child) {
if(child.isMesh){
children.push(child)
}
})
scene.add(model)
})
const tick = () =>
{
const elapsedTime = clock.getElapsedTime()
raycaster.setFromCamera(mouse, camera)
if(model){
const stones= [children[2],children[3],children[4],children[5],children[6],children[7],children[8],children[9],children[10],children[11],children[12],children[13],children[14],children[15],children[16],children[17],children[18],children[19],children[20],children[21],children[22]]
const intersects = raycaster.intersectObjects(stones)
if(intersects.length)
{
stones.scale.set(1.2, 1.2, 1.2)
}
else
{
stones.scale.set(1, 1, 1)
}
}
// Update controls
controls.update()
lerp.current = GSAP.utils.interpolate(
lerp.current,
lerp.target,
lerp.ease
)
if (model) model.position.z = lerp.current
// Render
renderer.render(scene, camera)
// Call tick again on the next frame
window.requestAnimationFrame(tick)
}