1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WebGL でローカルでテクスチャを読み込めない!

Posted at

ウェブでも3Dグラフィック扱いたい!と思って Three.js をいじり始めたのですが、ローカルでテクスチャを読み込むにあたってつまづいたのでメモ。

これは何が原因かというと、プログラマブルシェーダーというのが悪用されるのを防ぐため、WebGLでは別ドメインから読み込んだ画像などをテクスチャとして使用できないことが原因だそうです。
※CORSというので明示的に許可した場合は除くとのこと

特に chrome はこの規制が厳しいらしく、ローカルにあるファイルは一切読み込めない!

ということで、都度サーバに上げて確認してもいいのですが、めんどくさいので chrome 起動の際にオプションつけると解決します。

$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --allow-file-access-from-files

参考:webGLでローカルにあるテクスチャファイルを使用したい場合 | youth

これで、ローカルでもテクスチャ読み込み放題です。
プログラマブルシェーダー(っていうかシェーダー)とか、まだ全然わかってないけれども、とりあえずはよかったね!

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?