SpaceToast

Members
  • Content count

    14
  • Joined

  • Last visited

  1. What's next?

    I'd love to see any of the following: LOD enhancements: LOD blending. Not sure what the "cheapest" method to reduce pop-in is. 1-bit pattern masks? Load and dispose at LOD. A "set it and forget it" method to load a model/scene file into the current scene when needed, then dispose of it when no longer needed. This would be quite helpful for building large/streaming type worlds, but useful even for small scenes to reduce load times. (Everyone hates a loading screen!) More user-friendly shaders: Built-in primitives. Rather than Road, Fire, Brick, etc. a set of option-heavy primitives like SimplexNoise, CellTurb, Gradient, Tiles, SphereMap, PlanarMap, etc. Primitive combiners. In prerendered 3d, nesting nodes like gradients, noise patterns and falloff types allows for the creation of extremely rich non-repeating textures from very short descriptors. Could something similar be done to generate pixel shaders? A simpler method to remap keys and other input methods (as opposed to just adding and removing keys). (On background, I'm working on a virtual museum of Earth history, in which every step you take represents a million years. So, a mesh-heavy scene that's almost 2 miles long. I'm an old hat at animation, but new to realtime 3D. What I'm mainly finding is that the bottleneck isn't the amount of content to be rendered, but getting that content to the user's browser in the first place.)
  2. Altering the Vertices of an Imported Mesh

    Ahh! Good point, Kosh. Object.setVerticesData() does not update normals. Unless that's desirable (or you're also creating a normals array manually), object.updateMeshPositions() may still be the best way to go. I'll leave my four-step answer alone.
  3. Altering the Vertices of an Imported Mesh

    Appreciate the help, crew. (And yeah, my Float32 conclusion came from a coding typo on my part!) What I'm really trying to do is map out the "gotchas" around editing vertex data in bjs. What I'm mostly finding is that the better-documented updateMeshPositions() method is rather delicate and unnecessarily complex--at least in my specific case of using a webworker to generate the new vertex arrays. Possibly in most cases.
  4. Altering the Vertices of an Imported Mesh

    Thanks, JC. In other words--to surface the lede from your code--you can replace vertex data directly with object.setVerticesData(), but only if your new data is in an [explicitly created] Float32 array. Is there any advantage to using an object.setVerticesData() function?
  5. Altering the Vertices of an Imported Mesh

    Hmm. Might be a bug. In Chrome and Firefox, at least, only editing the values of the position array in situ appears to work. Regardless, for anyone using this thread for future reference, you'll need to take the following steps to alter an imported mesh. (Here's a working playground to follow along.) Kosh (All Kosh?) Thanks again! Rip out the mesh's vertex position data & stuff it back in, with updateable set to true: var pos = bb.getVerticesData(BABYLON.VertexBuffer.PositionKind); bb.setVerticesData(BABYLON.VertexBuffer.PositionKind, pos, true); Rip out the mesh's vertex normals & stuff them back in, with updateable set to true: var nm = bb.getVerticesData(BABYLON.VertexBuffer.NormalKind); bb.setVerticesData(BABYLON.VertexBuffer.NormalKind, nm, true); Call updateMeshPositions() on the mesh: bb.updateMeshPositions(positionFunction, true); Create a function to edit the vertex positions, for updateMeshPositions() to trigger. Note that updateMeshPositions() automatically passes the vertex position array of the mesh that calls it as an argument to your position function: var positionFunction = function(positions) { var numberOfVertices = positions.length/3; for (var i = 0; i < numberOfVertices; i++) { positions[i*3] = Math.random(); positions[i*3+1] = Math.random(); positions[i*3+2] = Math.random(); }; };
  6. Altering the Vertices of an Imported Mesh

    Very elegant! Is it possible to replace all of the existing vertex positions in a single copy operation, like existingVertices = newPositionArray; or would I always need to loop through the vertex array replacing values one by one?
  7. Hey crew. I've run up against trouble trying to move the vertices of an imported mesh. (So far I've tried a .babylon file and .glb.) Here's a Playground example where I've added a randomize-vertex-positions function to the glTF Importer (Boombox) example. Upon loading the scene file, we do this: //Add a "do this once the mesh loads" function to the example: var bb = scene.getMeshByName("BoomBox"); //Get the newly-loaded mesh bb.updateable = true; //Not clear if this does anything var positions = bb.getVerticesData(BABYLON.VertexBuffer.PositionKind); //Copy the mesh's vertex positions into an array var numberOfVertices = positions.length/3; //Randomize the vertex coordinates in the array for(var i = 0; i<numberOfVertices; i++) { positions[i*3] = Math.random()*5; positions[i*3+1] = Math.random()*5; positions[i*3+2] = Math.random()*5; }; var positionFunction = function() { //Create a function for updateMeshPositions to call... bb.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions); //...where we replace the old vertex data with our array }; bb.updateMeshPositions(positionFunction, true); //Call that updateMeshPositions function //And... nothing happens. The boombox remains as it was at import. No change. Any thoughts on what I might be doing wrong?
  8. Referencing Lights Imported From Blender

    Your intuition was right, Wingnut. Not a Babylon problem. It was one of those Javascript issues I can never seem to keep straight: BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, function() {console.log(scene.getLightByName("sun"));}); ...creates a find-the-sun function that will be called when the loader finishes. This works! BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, console.log(scene.getLightByName("sun"))); ...fires console.log() immediately when Append() runs, rather than waiting for the loader to finish. Hence, so sun!
  9. How would I reference a light imported from Blender? I'm appending a scene with a directional light (sun) as follows: BABYLON.SceneLoader.Append("", "museumScene.babylon", scene); Now, if I add a "fire when fully imported" function to return the array of lights in the scene, I see my sun in the console just as I'd expect: BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, console.log(scene.lights)); However, if I try to reference the sun in the normal way, I only get null: BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, console.log(scene.getLightByName("sun")));
  10. Excellent! Output works perfectly now. Thanks, JC.
  11. Does anyone have experience using the Tower of Babel exporter with the Mac version of Blender? My test scenes fail with the following log error (in both Bforartists and the "mainline" Blender app). Is there perhaps a file-writing peculiarity under OS-X? I'm too weak at Python to dig any deeper before reaching out, I'm afraid... [snip] ========= Writing of files started ========= ========= An error was encountered ========= File "/Users/me/Library/Application Support/Bforartists/2.79/scripts/addons/tower-of-babel/js_exporter.py", line 177, in execute self.to_script_file() File "/Users/me/Library/Application Support/Bforartists/2.79/scripts/addons/tower-of-babel/js_exporter.py", line 217, in to_script_file self.world.initScene_script(file_handler, typescript_file_handler, self.needPhysics, self) File "/Users/me/Library/Application Support/Bforartists/2.79/scripts/addons/tower-of-babel/world.py", line 84, in initScene_script file_handler.write(indent + 'scene.fogMode = ' + self.fogMode + ';\n') ERROR: Can't convert 'int' object to str implicitly ========= end of processing ========= elapsed time: 0 min, .0047 secs test_scene.blend
  12. Normal Map Intensity?

    Is there a method of altering the intensity of a bump map (normal map) from within Babylon.js? Something along the lines of: var bumpyMaterial = new BABYLON.StandardMaterial("bumpy", scene); bumpyMaterial.bumpTexture = new BABYLON.Texture("bumpy_normal_map.jpg", scene); bumpyMaterial.bumpTexture.alpha = 0.5; More generally I suppose, how would one fade a texture map of any kind during runtime?
  13. Rotating a Vector

    Thank you both. So to broaden Temechon's suggestion for the next newbie like myself, a simple function taking a vector and a quaternion and returning the vector rotated would be as follows: function rotateVector(vect, quat) { var matr = new BABYLON.Matrix(); quat.toRotationMatrix(matr); var rotatedvect = BABYLON.Vector3.TransformCoordinates(vect, matr); return rotatedvect;}
  14. Rotating a Vector

    What would be the most straightforward way to rotate a Vector3, by either an euler angle or a quaternion? I feel like there must be a simpler way than my ludicrous hack: Two invisible cubes, with the vector assigned to the child, the rotation assigned to the parent, and the difference taken between their positions in world space using .getAbsolutePosition().