Giter Club home page Giter Club logo

Comments (9)

ssatguru avatar ssatguru commented on June 20, 2024

should be possible. I will look into it
Thanks

from babylonjs-editcontrol.

accounts-ideashaper avatar accounts-ideashaper commented on June 20, 2024

I figured it out. All you have to do is import babylon at the top of the .js file:
import * as BABYLON from 'babylonjs';

And then export the full path at the bottom:
export default org.ssatguru.babylonjs.component.EditControl;

Then you can import the control where you need it with:
import EditControl from '../lib/EditControl.js';

and use it as you would otherwise with:
var ctrl = new EditControl(mesh,camera, canvas, 0.75, false);

Thanks for doing this...

from babylonjs-editcontrol.

ssatguru avatar ssatguru commented on June 20, 2024

Nice.
I am still looking into how to package it into npm repository.

from babylonjs-editcontrol.

focomoso avatar focomoso commented on June 20, 2024

That would make things much easier...

from babylonjs-editcontrol.

ssatguru avatar ssatguru commented on June 20, 2024

I have added this to npm . See readme.
For now I am thinking of leaving this as vanilla "namespaced" JavaScript application.
Converting it to a nodejs or amd module, adds module system dependencies .
Doesn't webpack provide a way to add non-module third party apps?

from babylonjs-editcontrol.

focomoso avatar focomoso commented on June 20, 2024

It does, but not using the script tag. I've tried to get this working by using

import * as EditControl from 'babylonjs-editcontrol';

which is how you import Babylon. I had to edit the package.json adding the line:

"main": "dist/EditControl.js",

so webpack could find the right file, but the problem is that if the edit control doesn't add Babylon, webpack can't compile it (because BABYLON isn't defined).

from babylonjs-editcontrol.

ssatguru avatar ssatguru commented on June 20, 2024

The EditControl is not a module. It does not export anything and it does not import anything.
WebPack provides "exports-loader" and "imports-loader" to add exports and imports to such apps.
See if this works

var EditControl=require("exports-loader?org.ssatguru.babylonjs.component.EditControl!imports-loader?BABYLON=babylonjs!babylonjs-editcontrol/dist/EditControl");

you will, ofcourse, have to npm install the following
exports-loader
imports-loader
babylonjs
babylonjs-editcontrol

from babylonjs-editcontrol.

ssatguru avatar ssatguru commented on June 20, 2024

have added

"main": "dist/EditControl.js",

to the package json

from babylonjs-editcontrol.

ssatguru avatar ssatguru commented on June 20, 2024

new version adds module support

from babylonjs-editcontrol.

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.