Hello, I am doing some webgl extensions with three.js following the ExternalRenderer sample, I have created a CustomRenderer like this:
<SPAN class="keyword token">public</SPAN> <SPAN class="token function">setup</SPAN><SPAN class="punctuation token">(</SPAN>context<SPAN class="punctuation token">:</SPAN> __esri<SPAN class="punctuation token">.</SPAN>RenderContext<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// Setup webgl renderer</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>renderer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">WebGLRenderer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
context<SPAN class="punctuation token">:</SPAN> context<SPAN class="punctuation token">.</SPAN>gl<SPAN class="punctuation token">,</SPAN>
alpha<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">,</SPAN>
antialias<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">true</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>renderer<SPAN class="punctuation token">.</SPAN>autoClear <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// this.renderer.setPixelRatio(window.devicePixelRatio);</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>renderer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setViewport</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>view<SPAN class="punctuation token">.</SPAN>width<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>view<SPAN class="punctuation token">.</SPAN>height<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>scene <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Scene</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>camera <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">PerspectiveCamera</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Then load a texture from a url, and add it to scene, the code looks like this:
<SPAN class="keyword token">const</SPAN> extent <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">.</SPAN>extent<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> elevation <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">.</SPAN>elevation<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> unit <SPAN class="operator token">=</SPAN> Math<SPAN class="punctuation token">.</SPAN>PI <SPAN class="operator token">/</SPAN> <SPAN class="number token">180.0</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="punctuation token">(</SPAN>EarthRadius <SPAN class="operator token">+</SPAN> elevation<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>extent<SPAN class="punctuation token">.</SPAN>xmax <SPAN class="operator token">-</SPAN> extent<SPAN class="punctuation token">.</SPAN>xmin<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> unit<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> height <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>extent<SPAN class="punctuation token">.</SPAN>ymax <SPAN class="operator token">-</SPAN> extent<SPAN class="punctuation token">.</SPAN>ymin<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> unit<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> segs <SPAN class="operator token">=</SPAN> <SPAN class="number token">36</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> geometry <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">PlaneBufferGeometry</SPAN><SPAN class="punctuation token">(</SPAN>width<SPAN class="punctuation token">,</SPAN> height<SPAN class="punctuation token">,</SPAN> segs<SPAN class="punctuation token">,</SPAN> segs<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> textureLoader <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">TextureLoader</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> texture <SPAN class="operator token">=</SPAN> textureLoader<SPAN class="punctuation token">.</SPAN><SPAN class="token function">load</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">.</SPAN>url<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> material <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">MeshBasicMaterial</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// color: 0xffff00,</SPAN>
map<SPAN class="punctuation token">:</SPAN> texture<SPAN class="punctuation token">,</SPAN>
wireframe<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN>
opacity<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">0.5</SPAN><SPAN class="punctuation token">,</SPAN>
transparent<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">,</SPAN>
alphaTest<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">0.05</SPAN><SPAN class="punctuation token">,</SPAN>
side<SPAN class="punctuation token">:</SPAN> DoubleSide
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>plane <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Mesh</SPAN><SPAN class="punctuation token">(</SPAN>geometry<SPAN class="punctuation token">,</SPAN> material<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> srcCoord <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>
<SPAN class="punctuation token">(</SPAN>extent<SPAN class="punctuation token">.</SPAN>xmin <SPAN class="operator token">+</SPAN> extent<SPAN class="punctuation token">.</SPAN>xmax<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">/</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">(</SPAN>extent<SPAN class="punctuation token">.</SPAN>ymin <SPAN class="operator token">+</SPAN> extent<SPAN class="punctuation token">.</SPAN>ymax<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">/</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN>
elevation
<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> destCoord <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
externalRenderers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">toRenderCoordinates</SPAN><SPAN class="punctuation token">(</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>view<SPAN class="punctuation token">,</SPAN>
srcCoord<SPAN class="punctuation token">,</SPAN>
<SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN>
SpatialReference<SPAN class="punctuation token">.</SPAN>WGS84<SPAN class="punctuation token">,</SPAN>
destCoord<SPAN class="punctuation token">,</SPAN>
<SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="number token">1</SPAN>
<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">const</SPAN> transform <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Matrix4</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
transform<SPAN class="punctuation token">.</SPAN><SPAN class="token function">fromArray</SPAN><SPAN class="punctuation token">(</SPAN>
externalRenderers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">renderCoordinateTransformAt</SPAN><SPAN class="punctuation token">(</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>view<SPAN class="punctuation token">,</SPAN>
srcCoord<SPAN class="punctuation token">,</SPAN>
SpatialReference<SPAN class="punctuation token">.</SPAN>WGS84<SPAN class="punctuation token">,</SPAN>
<SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Float32Array</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">16</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
transform<SPAN class="punctuation token">.</SPAN><SPAN class="token function">decompose</SPAN><SPAN class="punctuation token">(</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>plane<SPAN class="punctuation token">.</SPAN>position<SPAN class="punctuation token">,</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>plane<SPAN class="punctuation token">.</SPAN>quaternion<SPAN class="punctuation token">,</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>plane<SPAN class="punctuation token">.</SPAN>scale
<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>scene<SPAN class="punctuation token">.</SPAN><SPAN class="token function">add</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>plane<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>I have set transparent to true, and opacity to 0.5 , but the texture loaded looks not transparent, but it it looks transparent in three.js.
So, how to make texture loaded transparent in external renderer?