سؤال

I'm trying to use Meteor with Three.JS. The meteorite package I'm using for Three.JS is here: https://github.com/nozpheratu/three-meteor However, while I can do basic Three.JS functions, I am unable to do things such as instantiate a new Euler object (with the code var x = new THREE.Euler(0,0,0,'xyz')), I get the error TypeError: undefined is not a function. This happens with a few other miscellaneous things. I tried manually importing the Three.JS Euler class, but that told me that I was missing some other class, etc. Basically, is there a way to manually get three.js into Meteor? I tried adding the three.min.js to no avail either.

Thanks

هل كانت مفيدة؟

المحلول

I did this with three.js version 62 by making it a meteor package, then pointing the environment variable PACKAGE_DIRS to the root directory containing your local packages so they show up in "meteor list".

Package.describe({
    summary: 'threejs webgl 3D graphics library'
});

Package.on_use(function (api) {
    api.add_files('client/compatibility/three.js', ['client']);
    api.add_files('client/OrbitControls.js', ['client']);
    api.export('THREE');
});

نصائح أخرى

I answered a question earlier that happened to be a bit old. See my answer here: https://stackoverflow.com/a/30796259/3450634

After playing around with Meteor for a few days, I've learned that it's not necessary to always have a package for a library you want to use. I cannot say this solution works for everything, but it has allowed me to use three.js without any hackery.

Place your three.min.js file within client/compatibility and create a new file within the client folder called main.js Within your main.js file enter the following code:

Meteor.startup(function() {
    // your three code here.
});

And viola! This should work perfectly fine. I'm using three.js r71 and meteor v1.1.0.2

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top