Reputation: 13
i want to use the texture from new THREE.Texture(canvas)
to the PointsMaterial.
however, it does not work. the canvas is on the top right. but the CubeGeometry
only has the white point.
var texture = new THREE.Texture( canvas );
texture.needsUpdate = 1;
when i use the texture from new THREE.TextureLoader().load( "snowflake5.png" )
it worked.
this is demo: https://codepen.io/anon/pen/JNezgM
Where was my fault?
Upvotes: 1
Views: 134
Reputation: 104833
If you instantiate a texture from a canvas element using the following pattern, you must set the needsUpdate
flag to true
.
var texture = new THREE.Texture( canvas );
texture.needsUpdate = true;
Alternatively, you can use this pattern, and the needsUpdate
flag will be set for you:
var texture = new THREE.CanvasTexture( canvas );
Regarding your bug, your code does not work because:
true === 1 // false
three.js r.85
Upvotes: 2