Hello everyone,
I am following the installation instructions from https://github.com/tweenjs/tween.js/ to include TweenJS in my ThreeJS project.
My script is: script src=“Lib/tweenjs/tween.umd.js”
My code is:
const coords = { x: 0, y: 0 }; // Start at (0, 0)
const tween = new TWEEN.Tween(coords); // Create a new tween that modifies ‘coords’.
My error when I try to run this on my website is: Can’t find variable: TWEEN
I’m not sure what I’m missing here, and any help would be greatly appreciated.
And what if you use this link https://cdnjs.cloudflare.com/ajax/libs/tween.js/16.7.0/Tween.js
for the source of script
tag (taken from the codepen on their github page)?
Thanks for your reply, unfortunately I still see the same error. I also tried running
npm install tweenjs
in my project folder, but the error remains. Is it possible I need to include an import in my JS file in addition to this script source in my HTML file?
When you include tween.js
with a <script>
tag from a custom path, then installing npm modules makes no sense.
No. Please don’t make the common mistake by importing libraries twice. One time as a global script and the other time as an ES6 module.
I’m afraid you have to share your complete code as an editable live example or as a GitHub repo. Use the following fiddle as a code template: