Giter Club home page Giter Club logo

Comments (5)

frenchtoast747 avatar frenchtoast747 commented on June 2, 2024

I'll take a look and get back with you! Thanks!

from webgl-obj-loader.

frenchtoast747 avatar frenchtoast747 commented on June 2, 2024

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";

from webgl-obj-loader.

8Observer8 avatar 8Observer8 commented on June 2, 2024

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...

from webgl-obj-loader.

frenchtoast747 avatar frenchtoast747 commented on June 2, 2024

That's a good point. I'll keep digging.

from webgl-obj-loader.

frenchtoast747 avatar frenchtoast747 commented on June 2, 2024

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/[email protected]/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.

from webgl-obj-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.