Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hi...........
I want to load 3d model images in asp.net and also rotate them.
How to loaded 3d images(objects) in asp.net.
Please anyone help me........


What I have tried:

Does the asp.net can load the 3d images(objects)?
Posted
Updated 31-Jul-22 4:07am

1 solution

You can achieve this in atleast two ways that I can think of:
1. Insert 3D-Objects in a webpage using HTML5 and CSS only
2. Insert 3D-Objects in a webpage using jQuery plugin

Depends on the usecase, ease and your comfort.

1. For HTML & CSS, you would need HTML5 Canvas and then translate it using JavaScript, example[^]:
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Rotate an ASP.NET Image Control using HTML 5 Canvas by DotNetCurry.com</title>
    <script type="text/javascript">
        window.onload = function () {
            var canvas = document.getElementById("myCanvas");
            var context = canvas.getContext("2d");
            var imgID = '<%= Image1.ClientID %>';
            var imgObject = document.getElementById(imgID);
            var imgWd = 200;
            var imgHt = 200;
            imgObject.onload = function () {
                // move reference point to center of canvas
                context.translate(canvas.width / 2, canvas.height / 2);
                // rotate context by 45 degrees
                context.rotate(Math.PI * 45 / 180);
                context.drawImage(this, -(imgWd / 2), -(imgHt / 2), imgWd, imgHt);
            };
            // set the image source
            imgObject.src = "images/baby.jpg";
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Image ID="Image1" runat="server" 
            style="display:none" />
        <canvas id="myCanvas" width="400" height="400" 
            style="border:1px solid black;">
            Your browser does not support the Canvas Element
        </canvas>
    </div>
    </form>
</body>
</html>

2. For jQuery plugin based approach, example[^]:
HTML
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.interactive_3d.js"></script>
<div id="demo">
<img src="images/frame_1.png"> 
</div>
<script>
$(document).ready( function() {
$("#demo").interactive_3d({
frames: 38
});
});
</script>
<script>
$(document).ready( function() {
$("#demo").interactive_3d({
frames: 10, // The total number of images to be used as frames. The higher, the smoother your interaction will be. The default value is 10 frames.
cursor: "move", // The CSS style to indicate what cursor will show when the user hover the object. The default value is "move"
speed: 0, // The speed of the rotation in milliseconds delay. If you have small number of frames and the rotation seems too fast and not smooth, increase this value to 50 - 100 milliseconds delay. The default value is 0.
entrance: true, // Entrance <a href="https://www.jqueryscript.net/animation/">Animation</a>. Toggle this to false to turn it off. The default value is true.
preloadImages: true, // Let the script preload all the frames on initial load. Toggle this to false to turn it off. The default value is true.
touchSupport: true, // The script support touch events for mobile phones. If this interferes with your website behaviour, you can toggle this to false. The default value is true.
loading: "Loading..", // This only applies if preloadImages is true. This option let you show a loading indicator while the script is preloading the images. The option accepts HTML. Toggle this to false to turn this off. The default value is "Loading.."
autoPlay: false // This option will superseded entrance option. The 3D object will start rotating automatically if autoPlay is not false. This option accepts the speed of the rotation in milliseconds delay. The default value is false.
});
});
</script>
There are more plugins that can do same/similar job. You need to look for based on your need.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900