Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with building geometry and shading #142

Open
davidh71 opened this issue Nov 2, 2024 · 0 comments
Open

Help with building geometry and shading #142

davidh71 opened this issue Nov 2, 2024 · 0 comments

Comments

@davidh71
Copy link

davidh71 commented Nov 2, 2024

Hi, I'm coming over from babylon - hoping this library can be more performant and it looks to be!
I need to build my own custom meshes and i found your triangle example. I've tried adding to it without much success.

  • does the position.fromArray calculate the normals ?
  • is there other ways of specifying geometry
  • why is the model black in my example?

thanks for pushing me in the right direction!!!!

var TRIANGLE_POSITIONS = [
    [-0.5, -0.5, 0],
    [0.5, -0.5, 0],
    [0, 0.5, 0],

	[0.5, -0.5, 0],
	[0, 0.5, -1],
	[0, 0.5, 0],

];

 clay.application.create("#main", {

	width: window.innerWidth,
	height: window.innerHeight,

    init: function (app) {
        var camera = app.createCamera([6, 15, 15], [0, 0, 0]);

        // Create a empty geometry and set the triangle vertices
        var geometry = new clay.StaticGeometry();
        geometry.attributes.position.fromArray(TRIANGLE_POSITIONS);


        var mesh = app.createMesh(geometry, {
            shader: 'clay.lambert'
        });
        mesh.material.set('color', 'blue');

        // Create lights.
        var directionalLight = app.createDirectionalLight([10, 10, 10]);
        directionalLight.shadowResolution = 1024;
        this._pointLight = app.createPointLight([30, 30, 0], 100, '#fff', 1);


        this._control = new clay.plugin.OrbitControl({
            target: camera,
            domElement: app.container
        });		
    },

    loop: function (app) {
		this._control.update(app.deltaTime);
	}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant