Closed 8Observer8 closed 4 years ago
I'll take a look and get back with you! Thanks!
I've never used AMD before, so I'm still learning, but I've found a couple of things that work.
1) Using require()
works. E.g. const OBJ = require("webgl-obj-loader")
2) Based on these docs, you must include a relative path along with file extensions. I got this to work: import * as OBJ from "./node_modules/webgl-obj-loader/dist/index";
CommonJS works fine for creating "bundle.min.js". I need AMD for publish on Plunker Playground. For example, my sample uses "gl-matrix" to transform (scale, rotation, position) a triangle: https://next.plnkr.co/edit/PkqSZGwhv9zKSnUNSiXo?preview
If glMatrix works then webgl-obj-loader should work too...
That's a good point. I'll keep digging.
I was able to get the linked Plunkr to work by using this require config:
requirejs.config({
baseUrl: ".",
paths: {
"gl-matrix": "https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min",
"webgl-obj-loader": "https://cdn.jsdelivr.net/npm/webgl-obj-loader@2.0.7/dist/webgl-obj-loader.min"
}
});
and this import
import * as OBJ from "webgl-obj-loader";
console.log(OBJ);
I updated the output of the UMD to not define a name (requireJS would only work for import OBJ from "OBJ";
) and instead exported an OBJ
object from the main output so that it was backward compatible with regular browser-based inclusion. This is released as version 2.0.7
on NPM.
I was never able to figure out why running TS locally with amd
and the import
wasn't working, but const OBJ = require("webgl-obj-loader")
is definitely working, so I'd suggest doing that for things outside of plunkr.
Hello,
I cannot compile my simple example using "model": "AMD".
Thank you for any help in advance.