x3dom

Error while rendering volume data with x3dom


I tried to set up the same volume renderer as in the official demo. Unfortunately, I always get the error Cannot read property 'textures' of null. I created a simple JSFiddle to demonstrate the problem. How do I make the volume show up?


Solution

  • Simple problem: You have been using the XHTML syntax. JSFiddle needs the HTML syntax. I have fixed this here:

    <X3D xmlns='http://www.web3d.org/specifications/x3d-namespace' showStat='true' showLog='false' width='500px' height='500px'>
      <Scene>
        <Background skyColor='0.0 0.0 0.0'>
        </Background>
        <VolumeData id='volume' dimensions='4.0 4.0 4.0'>
          <ImageTextureAtlas containerField='voxels' url='https://examples.x3dom.org/volren/aorta4096.png' numberOfSlices='96' slicesOverX='10' slicesOverY='10'>
          </ImageTextureAtlas>
          <OpacityMapVolumeStyle lightFactor='1.2' opacityFactor='6.0'>
          <ImageTexture containerField='transferFunction' url='https://examples.x3dom.org/volren/transfer.png'></ImageTexture>
          </OpacityMapVolumeStyle>
        </VolumeData>
      </Scene>
    </X3D>
    

    I think it was documented in the past, but nowadays I only found the simple examples where there are different examples for HTML and XHTML respectively.

    A similar answer can be found at https://stackoverflow.com/a/32201556/698496