【问题标题】:map: texture from new THREE.Texture(canvas) does not work地图:来自 new THREE.Texture(canvas) 的纹理不起作用
【发布时间】:2017-05-22 13:20:53
【问题描述】:

我想使用来自 new THREE.Texture(canvas) 的纹理到 PointsMaterial。 但是,它不起作用。画布在右上角。但是CubeGeometry 只有白点。

    var texture = new THREE.Texture( canvas );
    texture.needsUpdate = 1;

当我使用 new THREE.TextureLoader().load( "snowflake5.png" ) 的纹理时,它起作用了。

这是演示:https://codepen.io/anon/pen/JNezgM

我的错在哪里?

【问题讨论】:

  • 欢迎来到 SO。添加实时链接是可以的,但请在您的帖子中显示相关代码。

标签: javascript canvas three.js


【解决方案1】:

如果您使用以下模式从画布元素实例化纹理,则必须将needsUpdate 标志设置为true

    var texture = new THREE.Texture( canvas );
    texture.needsUpdate = true;

或者,您可以使用此模式,并为您设置 needsUpdate 标志:

    var texture = new THREE.CanvasTexture( canvas );

关于您的错误,您的代码不起作用,因为:

true === 1 // false

three.js r.85

【讨论】:

  • 得到它。谢谢。
猜你喜欢
  • 1970-01-01
  • 2016-09-27
  • 2018-03-22
  • 1970-01-01
  • 2013-01-25
  • 2014-07-16
  • 2014-08-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多