Skip to content

Conversation

@WestLangley
Copy link
Collaborator

MeshMatcapMaterial supports maps, bump maps, normal maps, object-space normal maps, displacement maps, alpha maps, flat-shading, alpha test, skinning, morphs, and local and global clipping.

MeshMatcapMaterial does not respond to lights. (The matcap image file encodes baked lighting). It will cast a shadow onto an object that receives shadows (and shadow clipping works), but it will not self-shadow or receive shadows.

The included example supports drag-and-drop, so the user can easily experiment with alternate matcap image files.

@WestLangley
Copy link
Collaborator Author

If preferred, the example can be modified to use the glTF LeePerrySmith model once #14806 is merged.

@WestLangley
Copy link
Collaborator Author

Bubblegum Knight

bubblegum_knight

@mrdoob mrdoob added this to the r97 milestone Sep 3, 2018
@mrdoob mrdoob merged commit 371ed47 into mrdoob:dev Sep 3, 2018
@mrdoob
Copy link
Owner

mrdoob commented Sep 3, 2018

Thanks!


if ( this.matcap === null ) {

var canvas = document.createElement( 'canvas' );
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrdoob Is referencing document here going to be a problem?

Is there another way we can have a default matcap?

This is actually not necessary. If the matcap is null, the model will render black, I guess. But for drag and drop support, ensuring the matcap was a valid texture to begin with makes things easy.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably create a DataTexture instead though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document.createElementNS

That presupposes a document, too. Is that OK? I'm not sure of the advantage of createElementNS here...

You can probably create a DataTexture instead though.

I tried a DataTexture first, but there were errors when the user replaced the default matcap with a Texture, or when drag-and-drop was used. It is possible I did something wrong, of course...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried a DataTexture first, but there were errors when the user replaced the default matcap with a Texture, or when drag-and-drop was used. It is possible I did something wrong, of course...

Oh, sounds like a bug. I'll have to investigate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to investigate.

Sweet. I appreciate that!

Here is my original attempt:

if ( this.matcap === null ) {

	this.matcap = new THREE.DataTexture( new Uint8Array( [ 255, 255, 255 ] ), 1, 1, THREE.RGBFormat, THREE.UnsignedByteType ); // white

	this.matcap.needsUpdate = true;

}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sounds like a bug. I'll have to investigate.

/bump

/ping @Mugen87 Should it be this, instead? Or doesn't it matter?

var canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );

Copy link
Collaborator

@Mugen87 Mugen87 Nov 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct. Otherwise we assume a HTML document context. Explicitly defining the HTML namespace via createElementNS() is more robust.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sounds like a bug. I'll have to investigate.

/bump

#15313

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

Successfully merging this pull request may close these issues.

3 participants