Comments (7)
It works :)
Thanks!
(sorry about the late reply, – I was on vacation)
from noa.
Hi, yes, some BJS folks have asked me to support this and I'd like to do it properly! But I'm not sure how best to go about it.
First, note that I've just pushed a build to the develop
branch to lay the groundwork for this - it now lets you pass in a babylon.js reference, rather than assuming it will be in global. I.e.:
var noaEngine = require('noa-engine')
var babylonJS = require('babylonjs')
var noa = noaEngine({
babylon: babylonJS,
})
Now with that said, the problem currently with import is that noa
treats babylon as peer dependency - that is noa doesn't import anything from Babylon directly, but various noa modules do new BABYLON.Vector3
and whatever. So I guess, the easiest way to do what you're talking about, today, would be for the game client to import only the specific classes noa
uses and pass them in:
import { Engine } from '@babylonjs/core/Engines/engine'
import { Scene } from '@babylonjs/core/scene'
import { Vector3 } from '@ babylonjs/core/Maths/math'
// .. and all the other classes noa needs
var noa = noaEngine({
babylon: {
Scene,
Engine,
Vector3,
// ...
},
})
I assume this would work but it's not a nice solution. The alternative would be for noa
to just declare a direct dependency on Babylon and import whatever classes it uses. However I guess this might make life difficult for a user who wants to use noa with a newer version of BJS, or with other BJS features that noa doesn't use.
Is your solution the same as one of those, or do you see other alternatives?
from noa.
Another option would be to declare @babylonjs/core as a peer depency in the noa's package.json as shown in this branch. Feel free to merge it if you want that approach, – otherwise I'll just pass the babylon modules as a parameter to noa, which works fine for me :)
from noa.
Hey, thanks for that link! It looks like I should do exactly that. I should probably also switch the rest of the code from require
over to import
- I've been meaning to do that eventually but didn't have a reason.
I'll work on this, thanks!
from noa.
I dove into this and it's working, but there were some complications. As a result I have pushed a branch to this repo that now uses @babylon/core
as a peer dep, but I also had to move the example contents into a separate repo:
https://github.com/andyhall/noa-examples
Can you do me a huge favor, and try pointing your project at the noa branch #es6-modules-babylon-as-peer
, and see if everything builds as expected? You will need to set your dependencies similarly to what's in the noa-examples
repo, like:
"dependencies": {
"@babylonjs/core": "^4.0.3",
"noa-engine": "github:andyhall/noa#es6-modules-babylon-as-peer"
},
Since these are big changes I'd really like to confirm that it works for someone besides me 😁
Thanks!
from noa.
Cheers mate!
I will push a release pretty soon.
from noa.
This is pushed to #master and also npm as v0.26.0
.
Let me know if anything breaks!
from noa.
Related Issues (20)
- Is there any way to use this as an es6 module? HOT 10
- Support gamepad input
- Outdated comment + note on blockMesh registration HOT 2
- Alpha blended mesh ordering issue HOT 2
- Terrain remeshing bug when block is neither solid nor opaque HOT 3
- Custom voxel occasionally leaves one side after removal. HOT 4
- UV offsets wrapping at edges of blocks HOT 2
- object meshing bug HOT 6
- Meshing with non-opaque blocks is incredibly slow + block textures with alpha dont work HOT 4
- custom renderMaterial performance (for animated textures) HOT 2
- Supporting noa HOT 2
- Does NOA support child meshes? HOT 3
- webgpu? HOT 2
- How to define new objects in NOA engine. HOT 5
- Optimal octreeBlockSize
- What is the best way to manually build worlds? HOT 2
- render all blocks even if covered HOT 1
- How to import an obj model?
- refresh the registry on the go HOT 2
- Making a set world.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from noa.