Jump to content

[SOLVED] - CreateGroundFromHeightMap VERY SLOW movement


MackeyK24
 Share

Recommended Posts

When using CreateGroundFromHeightmap... When i use the camera to move around on ground IS VERY SLOW and VERY CHOPPY... AND LOWERS FPS down to 15fps.

This is my code for creating Ground:

            // Parse scene native mesh and heightmap terrains
            var terrains:BABYLON.Mesh[] = this._scene.getMeshesByTags("[TERRAIN]");
            if (terrains != null) {
                terrains.forEach((terrain)=>{
                    console.log(terrain.metadata);
                    if (terrain.metadata != null && terrain.metadata.properties != null) {
                        if (terrain.metadata.properties.heightmapBase64) {
                            var tempBase64:string = terrain.metadata.properties.heightmapBase64;
                            var terrainWidth:number = terrain.metadata.properties.width;
                            var terrainLength:number = terrain.metadata.properties.length;
                            var terrainHeight:number = terrain.metadata.properties.height;
                            var minimumHeightLevel:number = terrain.metadata.properties.minimumHeightLevel;
                            var maximumHeightLevel:number = terrain.metadata.properties.maximumHeightLevel;
                            var groundTessellation:number = terrain.metadata.properties.groundTessellation;
                            var surfaceMaterialId:string = terrain.metadata.properties.surfaceMaterialId;
                            var surfaceMaterialInst:BABYLON.Material = null;
                            if (surfaceMaterialId != null && surfaceMaterialId !== "") {
                                var material:BABYLON.Material = this._scene.getMaterialByID(surfaceMaterialId);
                                surfaceMaterialInst = material;
                            }
                            BABYLON.MeshBuilder.CreateGroundFromHeightMap((terrain.name + "_Mesh"), tempBase64, {
                                width: terrainWidth,
                                height: terrainLength,
                                subdivisions: groundTessellation,
                                minHeight: minimumHeightLevel,
                                maxHeight: maximumHeightLevel,
                                updatable: true,
                                onReady: (mesh:BABYLON.Mesh) => {
                                    mesh.parent = terrain;
                                    mesh.scaling = terrain.scaling.clone();
                                    mesh.position.x -= terrain.position.x;
                                    mesh.position.z -= terrain.position.z;
                                    mesh.checkCollisions = true;
                                    if (surfaceMaterialInst != null) {
                                        mesh.material = surfaceMaterialInst;
                                    }
                                }
                            }, this._scene);
                        } else {
                            // TODO: Native Mesh - Note should try do all c# editor side
                        }
                    }
                });
            }

 

Any help would be awesome... as always :)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...