Closed levlups closed 5 years ago
I can't seem to get mesh-particle-system working. code:
import MPS from "./mesh-particle-system.js";
import { Texture } from "../../noalib/node_modules/@babylonjs/core/Materials/Textures/texture";
var tex = new Texture("img/blocks/stone.png", scene);
var capacity = 200;
var rate = 30; // particles/second
var mps = new MPS(capacity, rate, scene);
mps.setTexture(tex);
mps.mesh.position.x = 0;
mps.mesh.position.y = 0;
mps.mesh.position.z = 0;
this is run when a block is broken
mps.setMeshPosition(pos[0], pos[1], pos[2]);
mps.start();
Hi, unfortunately the mesh-particle-system
library was written back before Babylon had module exports. So it assumes that the BABYLON
object will be in global scope. You could probably use it that way if you try, but I believe that nowadays Babylon has several built-in ways of doing particles, so it would probably be easier to use those.
The only caveat is, any time you add your own mesh (e.g. the mesh for a particle system) to the Babylon scene, you'll need to call noa.rendering.addMeshToScene. This is because noa uses octrees to make scene mesh selection faster, and all new meshes need to be added to the octree somewhere.
i did put the object in global scope, but i changed the library to import everything mesh-particle-system.txt
In that case it should work, as long as you add:
noa.rendering.addMeshToScene(mps.mesh)
Or at least, it worked for me in a quick test. But Babylon did have some breaking changes in 4.0, so it's possible that it may not fully work.
here?
renders at 0,0,0 changing a few things, thanks
I tried to added but it doesnt work var makeParticles = require('./lib/particles') getting this error: Module not found: Error: Can't resolve './lib/particles'