-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
Added MeshMatcapMaterial #14828
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
Added MeshMatcapMaterial #14828
Conversation
|
If preferred, the example can be modified to use the glTF LeePerrySmith model once #14806 is merged. |
|
Thanks! |
|
|
||
| if ( this.matcap === null ) { | ||
|
|
||
| var canvas = document.createElement( 'canvas' ); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how it's done in WebGLTextures:
https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLTextures.js#L31
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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;
}There was a problem hiding this comment.
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' );
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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

MeshMatcapMaterialsupports maps, bump maps, normal maps, object-space normal maps, displacement maps, alpha maps, flat-shading, alpha test, skinning, morphs, and local and global clipping.MeshMatcapMaterialdoes 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.