Git Product home page Git Product logo

Comments (4)

MikesWei avatar MikesWei commented on August 19, 2024

see https://github.com/lebarba/WebGLVolumeRendering/tree/master/3DTextureConverter

from cesiummeshvisualizer.

MikesWei avatar MikesWei commented on August 19, 2024

JavaScript code:

      function convert3DTexture(rawData, width, height, depth, flipY) {
        var newWidth = width * maxTilesWidth;
        var newHeight = height * maxTilesHeight;
        var canvas = document.createElement('canvas');
        canvas.height = newHeight;
        canvas.width = newWidth;
        var ctx = canvas.getContext('2d');
        var imageData = ctx.getImageData(0, 0, newWidth, newHeight);

        var realPosX, realPosY;
        var index = 0;

        for (var z = 0; z < depth; z++) {
            for (var y = 0; y < height; y++) {
                for (var x = 0; x < width; x++) {
                    var value = rawData[index++];

                    realPosX = x + (z % maxTilesHeight) * width;

                    var yPos;
                    if (flipY) {
                        yPos = height - y - 1;
                    }
                    else {
                        yPos = y;
                    }

                    realPosY = yPos + parseInt(z / maxTilesWidth) * height;
                    var colorIdx = realPosX + realPosY * newWidth;
                    colorIdx *= 4;
                    imageData.data[colorIdx] = value;
                    imageData.data[colorIdx + 1] = value;
                    imageData.data[colorIdx + 2] = value;
                    imageData.data[colorIdx + 3] = value;

                }
            }
        }
        ctx.putImageData(imageData, 0, 0);
        return canvas;
    }

from cesiummeshvisualizer.

Ants-double avatar Ants-double commented on August 19, 2024

Thank you ,Now i get the canvas ,then ,i met the error ,when i put the canvas to the cubeTex:,the show nothing. Thank for you help,i use canvas.toDataURL('image/png');but not show the volume rendering.

from cesiummeshvisualizer.

Ants-double avatar Ants-double commented on August 19, 2024

ye. i use the C# code generate the texture ,it's work Thank you.

from cesiummeshvisualizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.