經過修改scenceview.js中tileBackground和defaultTileBackground中的png的base64編碼就能夠達到要求。 4.8中經過修改scenceview.js e.DEFAULT_TILE_BACKGROUND = typeof dojoconfig!=undefined &&dojoconfig.bg!=undefined?dojoconfig.bg:"原來的base64" 在html中引用init.js前html
<script >
var dojoconfig={bg:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAGUklEQVR4Xu3UQQ0AIBADQQhmeOPfGyTY2DkHnV461z53OAIEkgLTACR7F5rAFzAAHoFAWMAAhMsXnYAB8AMEwgIGIFy+6AQMgB8gEBYwAOHyRSdgAPwAgbCAAQiXLzoBA+AHCIQFDEC4fNEJGAA/QCAsYADC5YtOwAD4AQJhAQMQLl90AgbADxAICxiAcPmiEzAAfoBAWMAAhMsXnYAB8AMEwgIGIFy+6AQMgB8gEBYwAOHyRSdgAPwAgbCAAQiXLzoBA+AHCIQFDEC4fNEJGAA/QCAsYADC5YtOwAD4AQJhAQMQLl90AgbADxAICxiAcPmiEzAAfoBAWMAAhMsXnYAB8AMEwgIGIFy+6AQMgB8gEBYwAOHyRSdgAPwAgbCAAQiXLzoBA+AHCIQFDEC4fNEJGAA/QCAsYADC5YtOwAD4AQJhAQMQLl90AgbADxAICxiAcPmiEzAAfoBAWMAAhMsXnYAB8AMEwgIGIFy+6AQMgB8gEBYwAOHyRSdgAPwAgbCAAQiXLzoBA+AHCIQFDEC4fNEJGAA/QCAsYADC5YtOwAD4AQJhAQMQLl90AgbADxAICxiAcPmiEzAAfoBAWMAAhMsXnYAB8AMEwgIGIFy+6AQMgB8gEBYwAOHyRSdgAPwAgbCAAQiXLzoBA+AHCIQFDEC4fNEJGAA/QCAsYADC5YtOwAD4AQJhAQMQLl90AgbADxAICxiAcPmiEzAAfoBAWMAAhMsXnYAB8AMEwgIGIFy+6AQMgB8gEBYwAOHyRSdgAPwAgbCAAQiXLzoBA+AHCIQFDEC4fNEJGAA/QCAsYADC5YtOwAD4AQJhAQMQLl90AgbADxAIC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xiAcPmiEzAAfoBAWMAAhMsXnYAB8AMEwgIGIFy+6AQMgB8gEBYwAOHyRSdgAPwAgbCAAQiXLzoBA+AHCIQFDEC4fNEJGAA/QCAsYADC5YtOwAD4AQJhAQMQLl90AgbADxAICxiAcPmiEzAAfoBAWMAAhMsXnYAB8AMEwgIGIFy+6AQMgB8gEBYwAOHyRSdgAPwAgbCAAQiXLzoBA+AHCIQFDEC4fNEJGAA/QCAsYADC5YtOwAD4AQJhAQMQLl90Ag9l/10QBTEYHAAAAABJRU5ErkJggg=="}
</script>
複製代碼
傳入圖片base64編碼,這樣三維球就能夠按照咱們想要的顏色渲染,圖片分辨率最好是標準的2x2 4x4 8x8 16x16 32x32 64x64 128x128 256x256。 canvas
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鳥教程(runoob.com)</title>
</head>
<body>
<canvas id="myCanvas" width="256" height="256" style="border:1px solid #032832;">
您的瀏覽器不支持 HTML5 canvas 標籤。
</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
//ctx.fillStyle="#032832";
ctx.fillStyle="#032832";
ctx.fillRect(0,0,256,256);
var dataURL =c.toDataURL();
console.log(dataURL);
</script>
</body>
</html>
</script>
複製代碼