How to view mesh‘s pointscloud

var model = new BABYLON.Mesh(“model”, this._scene)
model.material=this._NormalMaterial
model.setVerticesData(BABYLON.VertexBuffer.PositionKind, tup[0], true) model.setVerticesData(BABYLON.VertexBuffer.ColorKind, tup[1], true)
model.setVerticesData(BABYLON.VertexBuffer.NormalKind, tup[2], true)
model.setIndices(tup[3])
1)this._NormalMaterial.wireframe= true,no problem,I can see model’s wireframe view
2)this._NormalMaterial.pointsCloud= true,I can see nothing in the scene, model disappeared,even set pointSize=2,
My question is How to view mesh‘s pointscloud,Is there another way to do this?

Please supply a repo of the problem in a playground using a simplified version of your project. This will enable us to see more clearly what the issue might be.

2 Likes

BABYLON.Effect.ShadersStore[“modelVertexShader”] = “precision highp float;\r\n”+

“attribute vec3 position;\r\n”+

“attribute vec4 color;\r\n”+

“varying vec4 v_color;\r\n”+

“uniform float time;\r\n”+

“void main(void) {\r\n”+

" gl_Position = vec4(position, 1.0);\r\n"+

" v_color=color;\r\n"+

“}\r\n”;

BABYLON.Effect.ShadersStore[“modelFragmentShader”] = “precision highp float;\r\n”+

“varying vec4 v_color;\r\n”+

“void main(void) {gl_FragColor = v_color;}\r\n”;

var createScene = function () {

// This creates a basic Babylon Scene object (non-mesh)

var scene = new BABYLON.Scene(engine);

// This creates and positions a free camera (non-mesh)

var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);

// This targets the camera to scene origin

camera.setTarget(BABYLON.Vector3.Zero());

// This attaches the camera to the canvas

camera.attachControl(canvas, true);

// This creates a light, aiming 0,1,0 - to the sky (non-mesh)

var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);

// Default intensity is 1. Let's dim the light a small amount

light.intensity = 0.7;

let vs = [0,0,-1,-1,1,-1,1,1,-1];

let cs = [0.5,0.5,0.5,1,0.5,0.5,0.5,1,0.5,0.5,0.5,1];

let is = [0,1,2];

var mMaterial = new BABYLON.ShaderMaterial("modelMaterial", 

scene,

    { 

        vertex: "model", 

        fragment: "model" 

    }, 

        {

        uniforms: [

            "time"

        ],

        attributes: [

            "position",

            "color"

        ],

    });//new BABYLON.NormalMaterial("modelMaterial", scene);//new ModelMaterial("modelMaterial", scene);

mMaterial.backFaceCulling = false

var model = new BABYLON.Mesh("model", scene);

model.material=mMaterial;

model.setVerticesData(BABYLON.VertexBuffer.PositionKind, vs,  true);

model.setVerticesData(BABYLON.VertexBuffer.ColorKind, cs, true);

model.setIndices(is);



scene.onKeyboardObservable.add((kbInfo) => {

        switch(kbInfo.event.key){

            case 'p':

                mMaterial.pointSize=20

                mMaterial.fillMode=2

                break;

            case 'w':

                mMaterial.fillMode=1

                break;

            case 's':

                mMaterial.fillMode=0

                break;

        }

});

return scene;

};

The above is my code in playground,Run it,Keyboard input “P”,can’t see pointsCloud,“W” wireframe normal.Why pointsCloud doesn’t work?

Please supply the playground not the code within it.

2 Likes

so sorry

Unfortunately I am not able to help with custom shader material. Here is a playground showing how it is done within the available features of babylon.js

glPointsize needs to be set by your shader https://www.babylonjs-playground.com/#LTD1RM#1

1 Like

Thank you very much!