DylanD

Members
  • Content Count

    416
  • Joined

  • Last visited

Everything posted by DylanD

  1. Yea, VsCode does do that, I guess I just didn't make sense of it. Il definitely try it more. I'm still pretty new to TS so I still have a lot to learn.
  2. Adding the return to the end of my function fixed the problem. Thank you very much! Final Code: var myPositionFunction=(particle, i, s)=>{ particle.rotation.y = Math.random() * 3.5; particle.position.y += 0.1; particle.checkCollisions = true; }; this.SPS = new BABYLON.SolidParticleSystem("sps",this.scene,{updatable:true}); var model = BABYLON.MeshBuilder.CreateBox("m",{width:0.03,height:0.03,depth:0.03}, this.scene); this.SPS.addShape(model,100,{positionFunction: myPositionFunction}); var mesh = this.SPS.buildMesh(); model.dispose(); this.SPS.updateParticle=(particle)=>{ particle.position.x +=this.xVel; return particle; } update=()=>{ this.SPS.setParticles(); }
  3. In this PG the update makes it rotate, I want my update function to be similar, however affect the position. When I copy paste that function into my code, I get an error on this line(79 of the PG), this error: Type '(particle: any) => void' is not assignable to type '(particle: SolidParticle) => SolidParticle'. [TSC] Type 'void' is not assignable to type 'SolidParticle'. The updateParticle in my other example code was not needed or used. So my problem seems to be some kind of typing error because of typescript with the solid particle system update particle function. Heres PG that I made, that shows what I'm trying to do. But when I put that same code into typescript I get an error on line 55(See the above error). Any ideas how I can get around this?
  4. Hi, I am trying to set up falling particles and I am using typescript. So far I have been able to create particles but no make them fall. Code to make particles: var myPositionFunction=(particle, i, s)=>{ particle.position.x = (Math.random() - 0.5); particle.position.y = (Math.random() - 0.5); particle.rotation.y = Math.random() * 3.5; particle.position.y += 0.1; particle.checkCollisions = true; this.SPS.updateParticle(particle); }; this.SPS = new BABYLON.SolidParticleSystem("sps",this.scene,{updatable:true}); var model = BABYLON.MeshBuilder.CreateBox("m",{width:0.03,height:0.03,depth:0.03}, this.scene); this.SPS.addShape(model,100,{positionFunction: myPositionFunction}); var mesh = this.SPS.buildMesh(); model.dispose(); this.SPS.updateParticle = function(){ } Whenever I try to make the this.SPS.update function it gives me this error Type '() => void' is not assignable to type '(particle: SolidParticle) => SolidParticle'. [TSC] Type 'void' is not assignable to type 'SolidParticle'. They only way I've been able to get that error to go away is if I put it in the myPositionFunction and put particle as one of its parameters. I also can't find much on using Solid particle systems in typescript at all. Any ideas on how to fix this ?
  5. will this work if I use standard material instead of a texture? I can't seem to get it working. So lets say I have something like: var material = new BABYLON.StandardMaterial("texture",scene); material.diffuseTexture = new BABYLON.Texture("textures/background.png",scene); material.diffuseTexture.uScale = 2.0; Any ideas what I should do to get them to have the qualities uScale, vScale, and uOffset etc? I had this working in javascript but when I switched over to typescript it kept giving me this error: "Property 'uScale' does not exist on type 'BaseTexture'. Did you mean 'scale'?" I did not mean scale. Goal: Use .uScale on the StandardMaterial Problem: VScode/typescript says uScale does not exist on BaseTexture @Deltakosh ping
  6. I can't it says I need an index.js to continue and the build never made one.
  7. whoops yea I just copy pasted over it... Successful build many warnings(only 3 actually), to be expected though, all of them were packages, cannon oimo etc. Still no index.js though. Heres what I've got: File Heirarchy: babylon-webpackTest( dist( bundle.js index.d.ts ) node_modules() index.html index.ts package-lock.json package.json tsconig.json web pack.config.ts ) Build Warnings and other text that came when I built it(npm run build with "build": "webpack"): Asset Size Chunks Chunk Names bundle.js 1.81 MiB main [emitted] main index.d.ts 11 bytes [emitted] [./index.ts] 755 bytes {main} [built] [./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 489 bytes {main} [built] + 1 hidden module WARNING in ./node_modules/babylonjs/babylon.js Module not found: Error: Can't resolve 'cannon' in '/node_modules/babylonjs' @ ./node_modules/babylonjs/babylon.js @ ./index.ts WARNING in ./node_modules/babylonjs/babylon.js Module not found: Error: Can't resolve 'earcut' in '/node_modules/babylonjs' @ ./node_modules/babylonjs/babylon.js @ ./index.ts WARNING in ./node_modules/babylonjs/babylon.js Module not found: Error: Can't resolve 'oimo' in '/node_modules/babylonjs' @ ./node_modules/babylonjs/babylon.js @ ./index.ts So its not creating an index.js I think when it builds right? Any ideas?
  8. Yea I will definitely let you know if I run into any other problems! Speaking of that I just added the comma, and now I get a "module.exports = { unexpected identifier error" should I have some kind of base then add your web packcode on top of that? Thanks Raanan!
  9. Update: I can't seem to get around "mode: "development" ", if I run npm run build then it gives me unexpected identifier error, if I add it to modules I get invalid configuration object, if I comment it out I get many errors one saying mode is not define, and if I add its own module.exports it underlines modules as an error. Any ideas? Sorry I need so much assistance.
  10. Thanks for the quick response, sorry I must have missed that somehow. I will keep you updated.
  11. @RaananW Hello again. Sorry as I'm not very well versed in web development... yet. However is this a typo or did I miss something? " We will also add an html file with a canvas (index.html): <!DOCTYPE html> <html> <head> <style> html, body { overflow: hidden; width: 100%; height: 100%; margin: 0; padding: 0; text-align: center; } #renderCanvas { width: 100%; height: 100%; touch-action: none; } </style> </head> <body> <canvas id="renderCanvas"></canvas> <script src="dist/index.js"></script> </body> </html> After adding index.ts we are ready to start developing. " You say "we will also add an html file with a canvas(index.html)", so I made a file and saved it as index.html, then immediately after you say "after adding index.ts we are ready to start developing". Should I have saved the html file as a ts, or maybe should I have made my own ts folder? Any ideas?
  12. Hey! Thanks I will try this and get back to you! Also thanks DeltaKosh for pinging.
  13. Hey you should set up a playground and share that, it is probably the best way to get help. Set one up here: https://playground.babylonjs.com then save and link it back here. My guess is It probably has something to do with this: BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true;
  14. Hey another question same topic but for a simplebutton how can I make it so that when I hover over the button with the mouse or when I click it, it won't become more transparent. as of right now when you hover over it, it becomes more transparent. ImageOnlyButtons also do this but I only need it for a simple button.
  15. So I had made a scene in javascript and am now putting it all into typescript. I am trying to use BABYLON.AdvancedDynamicTexture.CreateFullscreenUI("UI"); However I was getting an error: "Error: Cannot read property 'AdvancedDynamicTexture' of undefined" It seems that this was a common problem up until a fix last September, this fix: https://github.com/BabylonJS/Babylon.js/issues/2569 I have tried putting this in all my .ts files import * as BABYLON from "babylonjs"; import * as BABYLON from "babylonjs-gui" with tsconfig.json: "compilerOptions": { "target": "ES6", "module": "system", "moduleResolution": "node", "outDir": "js/build", "rootDir": "./ts", "noEmitOnError": true, "types": [ "babylonjs", "babylonjs-gui" ], }, But, it gave me a new error much more generic: Error: fetch error: 404 Not found instantiating http://localhost:3000/babylonjs loading http://localhost:3000/js/build/game.js loading app at fetch.js:37 so I went to the build folder and into the game.js and sure enough the first line is /// <reference path="../node_modules/babylonjs/babylon.d.ts" /> this line then shows the error [js] File '../node_modules/babylonjs/babylon.d.ts' not found. any ideas what to do? Just noticed this happens even if I don't use Babylon Gui
  16. Hi, I was wondering if there was a way to make the inner image smaller than the actual button, for example if my button is 90px by 90px how could I make the image 45px by 45px? I have already tried the different stretch modes and auto scale on button1.children[0] but it did not work, I have also tried button1.children[0].scaling = new BABYLON.Vector3(0.5,0.5,0.5); ,but that seemed to do nothing. The Gui button docs don't seem to say anything about this. Here is a playground I setup: https://playground.babylonjs.com/#Q9TCC2 Any ideas?