Hi, I’m trying to compose the most simple example for MeshBasicMaterial, but it fails to accurately render a color passed to the material constructor. The code looks like this:
<html>
<head><script src="three158.js"></script></head>
<body>
<canvas id="main" style="color: transparent; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;"></canvas>
</body>
<script>
window.onload = function() {
THREE.ColorManagement.enabled = false;
var cnv = document.getElementById('main'),
renderer = new THREE.WebGLRenderer({ canvas: cnv });
renderer.setClearColor(0x000000, 1);
//renderer.outputColorSpace = THREE.NoColorSpace;
renderer.render(new THREE.Mesh(new THREE.CircleGeometry(1, 4), new THREE.MeshBasicMaterial({ color: 0x0000c0 })), new THREE.OrthographicCamera(-1, 1, 1, -1, -1, 1));
};
</script>
</html>
I was expecting that this default setup would product a rhombus the color of which is exactly 0x0000c0
, but in practice it is 0x0014e1
with ColorManagement.enabled = false
, and 0x0010c0
otherwise.
Can somebody suggest how to get that damn color rendered correctly?
As a side note, setting renderer.outputColorSpace = THREE.NoColorSpace;
before the rendering call it produced the following error since COLOR_SPACES
doesn’t have a key for the NoColorSpace
Uncaught TypeError: Cannot read properties of undefined (reading ‘primaries’)
at Object.getPrimaries (three158.js:1699:38)
at getEncodingComponents (three158.js:19163:45)
at getTexelEncodingFunction (three158.js:19225:22)
at new WebGLProgram (three158.js:19946:5)
at Object.acquireProgram (three158.js:20903:15)
at getProgram (three158.js:29806:29)
at setProgram (three158.js:30042:16)
at WebGLRenderer.renderBufferDirect (three158.js:28949:21)
at renderObject (three158.js:29743:12)
at renderObjects (three158.js:29712:7)