looeee / discoverthreejs-site

Repo for the book Discover three.js!
https://discoverthreejs.com/
734 stars 96 forks source link

VectorKeyframeTrack references ".material.opacity" instead of ".position" #52

Open michaelnicol opened 2 years ago

michaelnicol commented 2 years ago

In the following code in the animation section of the book: Link to code block description

The following code is provided:

These three keyframes will make an object start at the center of the scene, move right, up, and forwards over three seconds, then reverse direction and move back to the center. Next, we’ll create a vector track with these keyframes.

import { VectorKeyframeTrack } from 'three';

const times = [0, 3, 6];
const values = [0, 0, 0, 2, 2, 2, 0, 0, 0 ];

const positionKF = new VectorKeyframeTrack('.material.opacity', times, values);

Since this is a Vector track, the key track property should be .position, not .material.opacity

looeee commented 2 years ago

Good catch, I will update this.