• Content count

  • Joined

  • Last visited

  • Days Won


Everything posted by brianzinn

  1. 3D Level Editor

    A bit on the early side, but I've been working on a 3D level editor and a game to go with it. I did look for 3D WebGL map editors when I started and didn't come across any open source (besides Voxel type) and I want to use ie: glTF models inside the editor and integrate in a game and one day a easy to use game creation engine. The editor itself will be open sourced (right now it's too tightly integrated with the game). Hoping it will make game development easier and faster for games with small maps (2D, 2.5D or 3D) - users often have better ideas than game creators ever could have imagined! Partly inspired by this project (I copied the game from @Temechon). The first version of the level editor is here: It's very PoC (Proof of Concept) material with lots of known issues and bugs. My next idea is instead of having the semi circle of things to instead have a tray that slides out in front of the board (and board slides back). Then I won't need all the popups with tiny text and it will work in VR. Right now the levels that you create can be published to the game, but not always published correctly, sorry . Publishing a level creates a URL you can share, though! To give an idea of how some bots work I created a 4 level tutorial: (if the roboloco logo is spinning a level is loading... i'm on an affordable tier!) The game received lots of constructive feedback from an Indie game dev meetup this week, so will be working on those ideas, but unfortunately really busy on other things as well So, back to the drawing board... again. Thanks!
  2. How do you teleport in vive/steamvr ?

    Did you try holding the trigger down for a short duration? According to the docs the trigger will fire the right event ( I don't have a Vive, so can't help otherwise.
  3. Some Bugs*... UI and other stuff...

    #3: linkWithMesh(...) only supports AbstractMesh or higher and is by design, as it's using boundingbox. (ie: change anchor to new AbstractMesh(...).
  4. Babylon.js: A double array to 3d

    Those will help along with many other possible optimizations ( JohnK's 250K box demo is pretty impressive and is running 60FPS on my laptop...
  5. Babylon.js: A double array to 3d

    My game builds blocks side-by-side in 3d as well. I do believe that using blocks and detecting occluded faces has a performance penalty. I'm not an expert, but imagine freezingWorldMatrix() or instances probably more performance gain ( You are measuring FPS, but it can be CPU or GPU constrained. Only way that I would know how much of a gain is by building and testing, but you were focusing on unneeded faces, so I thought it would be helpful to provide a specific solution
  6. Babylon.js: A double array to 3d

    I remember digging into this cool project once, if you really don't want to create the faces you don't need. You could do a similar loop, except he does 3d, while you are only in a double array, so your loop would be easier (ie: this example uses Array<Array<Array<...>>>). Basically creating meshes on the fly, but not adding a face if there is an adjoining block, which sounds like what you're after.
  7. I think only Samsung Internet (and Oculus Carmel) are supported for WebVR. If you want to increase the resolution then you can increase the canvas size. I don't know if the playground does automatically, but did you try adaptToDeviceRatio (last param)? ie: new Engine(canvas, true, undefined, true); edit: Just checked on my s8 against the playground. Try this PG: It shows engine.getHardwareScalingLevel() == 1 (with devicePixelRatios of 1, 2.5 and 3 - I tested on those 3) and window.devicePixelRatio = 3 on S8. I think you need to run this in a PG, but in your own code you can do the new Engine(...) 4th parameter true: engine.setHardwareScalingLevel(1.0/window.devicePixelRatio); Edit #2: another thing to consider is that your screen resolution is reduced when gear VR starts up.
  8. You did say you were using source, but I was just confirming. You are correct - docs are only for NPM package. Stepping through bjs TS code with these instructions, but only for ie: Playground, Sandbox: VS Code - Visual Studio - I've actually never tried to step through a dependent project in TypeScript - another option is to use babylon.max and step into JS. Hopefully somebody can help you out.
  9. [SOLVED] Strange behavior of material

    Confirmed 2 red spheres on FF 58.0.2 (64-bit) Windows on stable, but LATEST is correct red and green. edit: known issue. read more here:
  10. You are using the babylonjs source? I haven't had any issues with NPM and webpack - here are the docs: If that doesn't work can you provide more information - is your project TypeScript or JavaScript, which version of BabylonJS.
  11. Help! GL error since 3.2.0-alpha8

    Have you tried this: 1. add babylon.max.js as a script to your HTML: <script src=""></script> 2. add to webpack config: new webpack.ProvidePlugin({ BABYLON: 'babylonjs', }), I didn't actually try that, but should work. edit. or via externals:
  12. what about this? I think I'm missing something: edit: 2nd param in onCollideEvent has === "Ground", so when ground check object.rotation(Quaternion) and you can determine orientation - if ie: character is upright vs. landing on head?
  13. Here's another way to look at it - depends if object.attribute is an object or a data type. ie: these look the same, but have different results. This is copying the object reference: meshA.position = meshB.position vs. copying the object values: meshA.position.x = meshB.position.x meshA.position.y = meshB.position.y meshA.position.z = meshB.position.z You use clone() to create a new independent copy. You could, however, assign without clone() like above - I likely wouldn't inline this code: The clone is just a shortcut and actually creates a new Vector3: Vector3 also has a more memory efficient copyFrom() to not unnecessarily new up a Vector3 instance: If you look in the Math file you see lots of methods like xxx, xxxInPlace, xxxToRef. That lets use easily code our intentions and avoiding writing error-prone (and maybe harder to read) code in my example above
  14. You don't always have to clone the absolute position, but if you are going to *change* (ie: use for animation) or *assign* that Vector3, then cloning is good. Realize that the position is just a Vector3, so if you set two meshes to the same position: meahA.position = meshB.position When you move either mesh, both will move... It's not really the season, but check out this snowman that I just made for you. Try to remove the .clone() calls - it shows how the "instances" of position the same will lead to undesired results: position getAbsolutePosition() The takeaway is that BJS is highly optimized and will re-use the same instances. So, you need to be explicit in your code. edit: here is the code ( You are given access to an internal cache variable, which you're not meant to change. BJS *could* clone() it for you in the getter, but it's built for speed, so we clone() when required
  15. In the typescript it is explicitly an AbstractMesh, but I also tried in your PG and got an error: h.getBoundingInfo is not a function. I think it's from here: That getBoundingInfo() method starts on AbstractMesh: That method is not available on Node (That AbstractMesh derives from). Although, I don't see why it couldn't work for a Node.... the short answer is no. edit: can you get away with an empty mesh what you are trying to do?
  16. I know - it's the point of using a library that cross-browser/platform quirks are handled transparently. Did you find an underlying reason - like clientWidth/clientHeight being calculated incorrectly - or not reporting devicePixelRatio correctly? I searched when this was first discovered through Chrome bugs, but did not find anything.
  17. Are you running babylonjs on vive or rift ?

    "Completed" - would say no and that's why I like to call it "basic" support - not until the controllers with rays are shown like the the WinMR headset. I think we can use the GoogleVR models for Daydream (apache 2), but I can't find a Gear VR model. It is an improved situation in that at least the buttons work, so you can click on things and rotate/teleport. My game is playable in both and that has been my testing ground and initial goal. The daydream viewer I was using is an older one. I must add that it is still a great immersive experience in Samsung Internet - hope I didn't sound too harsh. It was a big WOW moment after only using cardboard The Oculus Browser doesn't have the best ratings, but is listed as supported on I'm interested to hear more about the rift and vive, too - Good topic!
  18. Are you running babylonjs on vive or rift ?

    I can add some thoughts on Oculus Gear VR and Daydream platforms. I don't use them a lot, since I got a Samsung Odyssey! I really wanted to support both of these VR options based on the # units sold. I did sorta try with Cardboard, but calibrating from a QR code scan (that part is manageable) and then converting to VRMetrics was a lot of headache, literally. I have a couple of posts with tips for all the needed pieces except actual VR Metric conversion should anybody want to take that further. 1. Samsung Internet is pretty reliable, but have had issues where I needed to restart it continuously. Don't think related to BJS specific. Didn't try Oculus Carmel browser. 2. I'm using top phones (S8 and Pixel2) and not full FPS, but it's acceptable. I'd be happy to try a benchmark page to get FPS. I've been watching the sceneOptimizer thread might help here. Scaling and aliasing - it's considerably harder to read smaller text on GUI Textures, even with high DPI on S8. 3. On Android Chrome I needed to set a couple of chrome://flags to get a good experience - not really something I'd expect regular users to do. Anyway, maybe you only wanted vive/rift, but lots of VR phones out there, too. I added very basic support for Gear VR and Daydream in that the trigger button and teleport rotations will work in 3.2. Would love to take this further and integrate the controller model in 3.2 (like WinMR does), if I wasn't super busy with a new project - will get there at some point. There is a post in Announcements if anybody wanted to make that a more seamless experience. Cheers.
  19. No worries. This does feel like something BJS should take care of, though. It's caught a few people already and I feel it should work without the meta tags. Otherwise, maybe we do need a Tips and Tricks page for stuff like this
  20. Basic Daydream support

    Basic support for Google Daydream controller PR was merged into BabylonJS, so should be in alpha11. Adding Daydream was more enjoyable and super easy compared to Gear VR. Sorry it's a long rambling post - it took me more time to write this forum post than the controller code itself! TLDR: Daydream controller has basic support (buttons work) - there's additional info here if you wanted to work on that or add a new controller. If you want to test your Daydream controller enable two flags in chrome://flags. As announced last month, BabylonJS added basic support for Gear VR. I put some instructions there for debugging GearVR as well. Setting up your phone for Daydream VR. I have a Pixel 2 and even with the Pixel 2, surprisingly you need to change some settings to get a good experience. Before I enabled these flags it was not an immersive experience even full screen (as I was testing it). That's unfortunate, but I think these features will be enabled by default in the future. Open up Chrome and visit chrome://flags to enable feature toggles for Gamepad extensions and WebVR: The nice thing about the Daydream Headset is that you can use it while plugged into USB for ADB over USB. For Gear VR you needed to debug over WiFi by design. You will need to follow instructions to enable USB debugging on your phone and the ADB instructions are in the GearVR post - just remember that WiFi is optional for Daydream. Should end up looking like this on your "Remote Devices" tab on Chrome on your desktop: The first time I plugged in the headset basically shows what the fallback (Generic) controller will output. This is helpful for you to figure out what indexes the buttons are in the Gamepad API. Here's the output: Pressing the home and app buttons did not output anything, so that lets you know that they aren't connected to the Gamepad API. The buttons do work on your phone, but for built-in OS features. What I did was grab the ID of the controller by adding a console.log and then create a new controller class. Here is the full output of what is generated from the Gamepad: What I want to do here is also outline steps to follow to add your own controller. There was a post about an unsupported 6DoF controller that led to a github issue (future feature) tagged "Help Wanted" ( to basically allow devs to dynamically register support for new controllers and it will probably work similar to how the Model Loaders work, so your registered controller class would get asked if it supports: ie: "Daydream Controller", but we are not there yet. Not to get too side tracked, but the cool thing about that idea is we could use NPM to create and load new controllers; maybe even all VR and make BabylonJS core even smaller. I think also a notion of priorities may be needed to override defaults vs. custom vs. generic, but I digress... Right now you need to manually edit some files to allow your custom Controller to run instead of the Generic controller. Looking at the PR you can see there's only a couple of lines of code to wire this controller in - it only needs to be detected before the generic fallback to be used. Assuming that your new controller supports 'pose' in the gamepad API then you could hook it up here: An astute reader who hasn't fallen asleep this far into the post may have noticed that 'hasPosition' is false and 'position' is null. That's basically saying that the controller does not support it's physical location in 3D space (it only knows gyro rotation). Typically when discussing 3DoF the position is available and nothing else (vs 6DoF with position & rotation) - here we are talking about rotational data being available and positional info not. ie: Vive has Lighthouse tracking and WinMR tracks controllers from HMD for accurate position of the controller in space and are both 6DoF. If you look in the BJS source and come across this in the WebVRCamera you would notice that the hasPosition property is "missing": That's because VRPose and GamepadPose are different. Here is the spec on GamepadPose (not in BJS source, but should be at some point because right now the parameters are typed as 'any'): OK, so I'll come back to that in another post as I want to in the future make this 3DoF controller a 6Dof experience. Some very naïve code that does not work would look like this, but I feel the changes belong in WebVRController and not in each Controller... this.capableOfPosition = vrGamepad.pose || vrGamepad.pose.hasPosition === true; if (!this.capableOfPosition) { // Device not capable of position (ie: 3DoF rotation only). // Position estimated from VR experience helper default height 1.7m. let controllerPosition = new BABYLON.Vector3(0.5, -1.0, -0.25); if (this._defaultModel && this._defaultModel.getScene().useRightHandedSystem) { controllerPosition.z *= -1; } controllerPosition.scaleInPlace(this.deviceScaleFactor); console.log('setting default controller position:', controllerPosition); this._defaultModel.position = controllerPosition; } So, next steps are to create the 6DoF experience to get away from rays coming from your eyes (think superman heat vision). It will be based, I think, by guessing first where your elbow is. The elbow is following your head rotations as your HMR rotates (and torso). Probably moving up a bit with your HMD and backwards when you look down. Then with the known gyro rotation of the controller you just position the controller where the hand would be based on that rotation and elbow position and forearm length. I'm going to try a few more experiments within the Daydream and Oculus environments to see how they position the elbow and when they guess your torso is rotating (I think camera intertia will play a role in that movement - like ignore low inertia maybe). I have to look again, but I don't think the default height and model scaling are available from VRExperienceHelper, but they need to be - they're definitely not in the 'update' method, but I think those need to be taken into account for a good experience. Controller models are still needed (also for GearVR). Luckily google VR has made models available under Apache 2.0 (one is low poly with texture) and I think we can bring those in - I'll let the license experts decide: Anway, first goal is reached that both Samsung and Google phone controllers buttons can interact through BJS. Of course, anybody else is fully welcome to implement those changes if they wanted. Let me know here so we don't do double work. I'll do another post later on when I start on the 6DoF stuff, but pretty busy for next 3-4 weeks. Cheers.
  21. I couldn't say really. Not too sure about the gory details, but WebGL 2.0 conforms closely to OpenGL ES 3.0, so I think it's just a forward looking step
  22. Since we're writing shaders we know if we used a vec4(x,y,z,w < 1.0) or discard, so it kind of makes sense. Here is more info from Khronos Group, if you're interested. glEnable(GL_ALPHA_TEST); Was deprecated in OpenGL 3.0 -- *NOT* WebGL afaik. WebGL is based on OpenGL ES 2.0:
  23. Some people were reporting the new version of Chrome had that problem, but otherwise you are onto something else.
  24. Did you try on different browsers? Also, can you check your viewport - some people reported needing special meta tag? ie: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=1">