# Anime.js V4 / Three.js / 3D-Model Update

**URL:** <https://forum.bootstrapstudio.io/t/anime-js-v4-three-js-3d-model-update/12217>\
**Category:** Webdesign Help\
**Created:** [May 10, 2025, 12:02pm UTC](https://forum.bootstrapstudio.io/t/anime-js-v4-three-js-3d-model-update/12217 "2025-05-10T12:02:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsphil](https://forum.bootstrapstudio.io/letter_avatar_proxy/v4/letter/b/7feea3/32.png) [@bsphil](https://forum.bootstrapstudio.io/u/bsphil)\
**Post date:** [May 10, 2025, 12:02pm UTC](https://forum.bootstrapstudio.io/t/anime-js-v4-three-js-3d-model-update/12217/1 "2025-05-10T12:02:32Z")

</div>

Hello everyone, I need help again with anime.js / three.js.

In version 3, I can animate (rotate) the 3D model.

In version 4, the code needs to be rewritten, but that doesn’t work for me. Unfortunately, I have almost no knowledge of JS.

Can anyone help me?

 ![Bildschirmfoto 2025-05-09 um 17.16.14](https://forum.bootstrapstudio.io/uploads/default/original/2X/4/4e3a8d5b89ec34dc55bf5d6245a2ed6f4ca54c94.jpeg)

Model is loading

Here’s V3, which works.

```auto
<!-- 3D-Viewer-Container -->
  <div id="viewer"></div>

  <!-- Three.js (r128) -->
  <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/build/three.min.js"></script>

  <!-- GLTFLoader -->
  <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/loaders/GLTFLoader.js"></script>

  <!-- Anime.js V3 -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.2/anime.min.js"></script>

  <script>
    // Container 
    const container = document.getElementById('viewer');
    const width = container.clientWidth;
    const height = container.clientHeight;

    // Scene, camera, Renderer
    const scene = new THREE.Scene();
    const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
    camera.position.z = 5.5;

    const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
    renderer.setSize(width, height);
    container.appendChild(renderer.domElement);

    // Light
    const light = new THREE.DirectionalLight(0xffffff, 2);
    light.position.set(3, 3, 3).normalize();
    scene.add(light);

    // GLTF-Loader
    const loader = new THREE.GLTFLoader();
    loader.load('https://modelviewer.dev/shared-assets/models/Astronaut.glb', gltf => {
      const model = gltf.scene;
      model.scale.set(1.5, 1.5, 1.5);
      scene.add(model);

      // Anime.js for rotation
      anime({
        targets: model.rotation,
        x: Math.PI * 2,
        y: Math.PI * 2,
        scale: .75,
        duration: 5000,
        easing: 'easeInOutSine',
        loop: true
      });
    }, undefined, error => {
      console.error('Fehler beim Laden des Modells:', error);
    });

    // Render-Loop
    function animate() {
      requestAnimationFrame(animate);
      renderer.render(scene, camera);
    }
    animate();

    // Responsive auf Fenstergröße
    window.addEventListener('resize', () => {
      const width = container.clientWidth;
      const height = container.clientHeight;
      camera.aspect = width / height;
      camera.updateProjectionMatrix();
      renderer.setSize(width, height);
    });
  </script>

```

and V4 Version

```auto
<!-- 3D-Viewer-Container -->
  <div id="viewer">
    <!-- test anime.js is working -Container -->
    <div class="square"></div>
</div>
  <!-- Three.js (r128) -->
  <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/build/three.min.js"></script>

  <!-- GLTFLoader -->
  <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/loaders/GLTFLoader.js"></script>

  <!-- Anime.js -->
  <script src="https://cdn.jsdelivr.net/npm/animejs/lib/anime.iife.min.js"></script>

  <script>
    // Container
    const container = document.getElementById('viewer');
    const width = container.clientWidth;
    const height = container.clientHeight;

    // Renderer
    const scene = new THREE.Scene();
    const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
    camera.position.z = 5.5;

    const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
    renderer.setSize(width, height);
    container.appendChild(renderer.domElement);

    // Light
    const light = new THREE.DirectionalLight(0xffffff, 2);
    light.position.set(3, 3, 3).normalize();
    scene.add(light);

    // GLTF-Loader 
    const loader = new THREE.GLTFLoader();
    loader.load('https://modelviewer.dev/shared-assets/models/Astronaut.glb', gltf => {
      const model = gltf.scene;
      model.scale.set(1.5, 1.5, 1.5);
      scene.add(model);

      // anime.js animation seperate file

    // Render-Loop
    function animate() {
      requestAnimationFrame(animate);
      renderer.render(scene, camera);
    }
    animate();

    // Responsive 
    window.addEventListener('resize', () => {
      const width = container.clientWidth;
      const height = container.clientHeight;
      camera.aspect = width / height;
      camera.updateProjectionMatrix();
      renderer.setSize(width, height);
    });
  </script>

```

and the anime.js file for animation

```auto
document.addEventListener("DOMContentLoaded", () => {
  // pull out the animate function from the global `anime`
  const { animate, utils, onScroll, createTimer, createTimeline, createScope, stagger, svg, waapi, engine, createDraggable, createSpring, eases, global, render } = anime;

const [container] = utils.$('.scroll-container');
const debug = true;

 
  
  
animate('.square', {
  x: '15rem',
  rotate: '1turn',
  duration: 2000,
  alternate: true,
  loop: true,
  autoplay: onScroll({ container, debug })
});
  

// this is a test.... canvas is flippig and shringing.. 
//this works, but only 2D
// "astro" was a test,, to name the model

const $demo = document.querySelector('canvas');
const $squares = $demo.querySelectorAll('.astro');

animate($demo, { 
  tan:5,
  scale: .75 ,
  rotateY: '1turn',
  alternate: true,
  loop: true,});

animate($squares, { x: '23rem' });
  
 
  });

```

---

<div class="post-metadata">

**Author:** ![kuligaposten](https://forum.bootstrapstudio.io/user_avatar/forum.bootstrapstudio.io/kuligaposten/32/1190_2.png) [@kuligaposten](https://forum.bootstrapstudio.io/u/kuligaposten)\
**Post date:** [May 16, 2025, 1:38pm UTC](https://forum.bootstrapstudio.io/t/anime-js-v4-three-js-3d-model-update/12217/2 "2025-05-16T13:38:45Z")

</div>

Here’s your Astronaut example using the latest versions of Three.js and Anime.js.

```html
<script type="importmap">
  {
    "imports": {
      "three": "https://cdn.jsdelivr.net/npm/three@0.176.0/build/three.module.js",
      "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.176.0/examples/jsm/"
    }
  }
</script>
<script type="module">
  import * as THREE from 'three';
  import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
  import { animate } from 'https://cdn.jsdelivr.net/npm/animejs/+esm';

  // Scene setup
  const scene = new THREE.Scene();
  const camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000);
  camera.position.z = 5.5;

  const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
  renderer.setSize(600, 600);
  document.body.appendChild(renderer.domElement);

  const light = new THREE.DirectionalLight(0xffffff, 12);
  light.position.set(3, 3, 3).normalize();
  scene.add(light);

  const loader = new GLTFLoader();

  loader.load(
    'https://modelviewer.dev/shared-assets/models/Astronaut.glb',
    (gltf) => {
      const model = gltf.scene;
      model.scale.set(1.5, 1.5, 1.5);
      scene.add(model);

      // Animate rotation
      animate(model.rotation, {
        y: {
          to: Math.PI * 2,
          duration: 5000,
        },
        loop: true,
        alternate: true,
        ease: 'easeInOutSine',
      });
    }
  );

  function render() {
    renderer.render(scene, camera);
    requestAnimationFrame(render);
  }
  render();
</script>

```

> **[Migrating from v3 to v4](https://github.com/juliangarnier/anime/wiki/Migrating-from-v3-to-v4)**
>
> JavaScript animation engine. Contribute to juliangarnier/anime development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![bsphil](https://forum.bootstrapstudio.io/letter_avatar_proxy/v4/letter/b/7feea3/32.png) [@bsphil](https://forum.bootstrapstudio.io/u/bsphil)\
**Post date:** [May 16, 2025, 4:15pm UTC](https://forum.bootstrapstudio.io/t/anime-js-v4-three-js-3d-model-update/12217/3 "2025-05-16T16:15:00Z")

</div>

wow

thx for your support
