• Content Count

  • Joined

  • Last visited

  1. Answering my own question... The solution I came up with was remove the event listeners from the InputText, and add a 'keydown' event listener to the canvas. Then in the canvas' keydown event, if the user presses enter, I process the chat input's current text and then clear it. Otherwise, I call the InputText.processKeyboard(e) method, with e being the KeyboardEvent passed via the onkeydown event, and let the InputText control process it from there. private _chatInput : GUI.InputText; ... document.getElementById('canvas').addEventListener('keydown', this._handleKeyDown.bind(this)); ... private _handleKeyDown(e : KeyboardEvent) : void { if (this._chatInput) { if (e.key === 'Enter') { this._chatInput.text = ''; } else { this._chatInput.processKeyboard(e); } } }
  2. onBeforeKeyAddObservable doesn't pick up Enter presses, and onBlurAddObservable doesn't differentiate between the user pressing Enter and clicking outside of the TextInput. What I'm trying to do is have a chat box, so that the user can send the message simply by pressing Enter; but I can't find a way to determine when the user actually presses Enter. Thanks
  3. Thanks for the tips. After trying to 'overlap' the edges of each chunk, I too had an issue with shading, particularly areas where the slope was steep. After some fiddling around, I managed to find another solution. What I did was created another canvas element on the document, as well as an image element to store the entire height map. Then I draw the image onto the canvas, based on which part of the map needs to be loaded (the canvas' context's API makes this very easy). Once the image is drawn on the canvas, I create the height map using canvas.toDataUrl(), instead of the original heightmap .png URL. Also, this means I only have one ground mesh, instead of 25. I still don't have code for loading new sections of the map (ie, re-drawing he image on the canvas with the new offset coordinates, then re-creating the ground mesh with the new dataURL.) This shouldn't take too long, once I finish I will test and see how the performance is. (hopefully it is a smooth transition! Perhaps someone who understands babylonJS more than I will already know if this is a good solution or not)
  4. I have a rather large map, and am therefore loading it in chunks 16x16 units in size. At any given time, there are are a total of 25 chunks loaded in a 5x5 grid. Each chunk has its own mesh, created using BABYLON.Mesh.createGroundFromHeightMap, and then I position the ground meshes at the appropriate locations. To create the height maps, I took the original map and cut it into chunks as well, and then pass it to each chunk. However, the edges of the ground meshes do not align, particularly if the edge has a steep slope. I attached a screenshot to better understand what I'm talking about. Whats the best way to fix this? Is using 25 ground meshes at a time a bad idea (should I only have 1 ground mesh at any given time)? Thanks
  5. Is there a way to suppress the warnings when compiling, for example, As far as I'm aware, I don't need to use any functionality cannon, earcut, or oimo (i'm getting warnings for all 3). If it matters, I'm using VSCode, TypeScript, and webpack-dev-server for my development environment. Thanks
  6. RIght, and actually the issue was with my code, and not with the call to getHeightAtCoordinates. Nonetheless thanks for the quick response Edit: Sorry, I can't get the PlayGround to load right now, so I can't check out the source code (I'm in China so my internet isn't the quickest at times)
  7. Awesome, it works great, thanks!
  8. I'm new to BJS, so I apologize if this is such a basic question. I have created a ground with a heightmap, and I am simply wondering how can I make sure all entities remain on the ground? Note that there is no physics in my game, so no jumping, etc. In other words, entities will always be 'stuck' to the ground. Right now when creating entities, I am using Vector3 and setting their Y value, but since I am using a heightmap this Y value obviously needs to be dynamic, depending on its current location on the ground. I was looking here at this link,_mesh_collisions_and_gravity , it seems like I can achieve this by setting the scene's gravity, and setting ground.checkCollisions = true. Considering my use case here is very basic (no physics, entites stuck to ground, etc.), is this still the proper way to handle this scenario? Thanks
  9. Sme

    ArcRotateCamera rotation speed

    Sorry to bump an older topic, but I too am unable to change (lower) the speed of the ArcRotateCamera. Setting the speed property doesn't seem to have any effect