background preloader

Displaying 3D Models in Web Pages using Webgl

Displaying 3D Models in Web Pages using Webgl
Standards for hardware accelerated 3D on the Internet are starting to become established. This is the first step towards immersive virtual worlds accessible through a browser window and for now, a nice way to display your models. The following tutorial (in four parts) shows how to embed Blender models in web pages using software from x3dom.org, the video tutorial runs through a Blender tutorial from their site. Here are the files created in the tutorial – greenMonkey.zip (not needed, easy to make your own). Here are the files created in the final part of the tutorial, models with textures – nes.zip Blender 2.5 Displaying 3D Models in Web Pages Using Webgl Exporting X3D Files and using X3DOM Part1 This part of the tutorial shows how to embed x3d code in a web page e.g. greenMonkey2.html (sky colour modified). Blender 2.5 Displaying 3D Models in Web Pages Using Webgl Exporting X3D Files and using X3DOM Part 2 Animation in the x3d Format Files used in tutorial – animationExamples.zip Related Links

FinalMesh - WebGL Technical information FinalMesh saves data as html, javascript and data files. Data files are scene tree, geometry, textures and optional shaders. HTML is for sample only, you may insert required parts from it to your own page. Integration Of course you may upload html file as is and everything will work, no changes are required. Internals We use AJAX for loading all data files, so all data downloaded in background and screen is updated when data is ready. After initializing, script loads objects tree and materials definitions. Data Format Geometry is saved in our own format. Scene tree is saved as text-json file. Data size and Geometry Quality Produced data files are quite compact. Binary encoding with lossy compression is right choice for most cases. Generated data files with precomputed per vertex normals are: about 3-6 times smaller than binary .STL files about 2.5-4 times smaller than .3DS about 3-5 times smaller than .OBJ Including HTML, CSS and Javscript. Customization Coming soon

Setup a Local Web Server on Windows, Mac, and Linux When developing a website, a web designer needs to be able to see his webpages the same way the end user would. Sometimes simply clicking on and viewing your HTML files in the web browser is enough, but if you want to test dynamic content, you will need to set up a local web server. Doing this is quite simple and can easily be accomplished on Windows, Mac, and Linux. There are many types of web servers available, but we will be using Apache as it is the most common server around, very easy to set up, and compatible with all major operating systems. Apache was designed for Unix-like operating systems. Linux falls under this category, and installation and configuration of Apache webserver can be done in one step. For graphical walkthrough, you can follow this tutorial. Most popular distributions allow you to install Apache without compiling it from source using one simple command. For Debian, Ubuntu, and Ubuntu-based distro: sudo apt-get install apache2 For Red Hat and CentOS

Webmasters! 3 Ways to 3D Web | Blend4Web This article explains how to place Blend4Web content on websites. Method #1 (Simplest): Self-Contained HTML File The possibility to export scenes from Blender to a single HTML file is one the most exciting features of Blend4Web. Such a file is an all-sufficient web page that can be opened with any standard browser and shared through any means (via email, USB drive/memory card, cloud storage, etc). You can, of course, share it online too. The main advantage of this method is its simplicity. 1. Of course, you can use HTML files as standalone web pages without any embedding too. Method #2 (More Optimized): Web Player + JSON The second method is an alternative to the first and the result seemingly looks the same: 3D content with control elements is embedded in a web page. Nevertheless, this method of embedding is different: instead of a single HTML file, a combination of the Web Player and a separate JSON file is used. Where do you get the Web Player? Note Then the .json file is loaded: That's it!

WebGL Tutorial: Interactive Model Viewer In this tutorial, you will learn how to create a simple WebGL interactive model viewer using the Three.js library. It will involve creating an html page, setting up the 3D scene, loading a model, and adding controls that will allow you to zoom, rotate, and pan around the object. A basic understanding of HTML, JavaScript, and 3D will come in handy here. Note that you will need a WebGL-enabled browser, eg Chrome, Firefox, Safari 5, Opera 12. You will also need to put these files on a server in order for them to work properly. STEP 1: Download Three.js First, download the latest Three.js package from Github. The minified version of Three.js. STEP 2: Make a new HTML Document Next we’ll create a new HTML document. STEP 3: Include the Three.js library and Supporting Scripts Place the minified Three.js file in your folder (I keep them in a folder named js) and link to the file from your HTML page. STEP 4: Add a Container for the WebGL Content STEP 5: Call the OnLoad Function Create some lights.

Getting Started with Three.js Introduction I have used Three.js for some of my experiments, and it does a really great job of abstracting away the headaches of getting going with 3D in the browser. With it you can create cameras, objects, lights, materials and more, and you have a choice of renderer, which means you can decide if you want your scene to be drawn using HTML 5's canvas, WebGL or SVG. For all the awesomeness of Three.js, there can be times where you might struggle. 1. I will assume that you have at least a passing knowledge of 3D, and reasonable proficiency with JavaScript. In our 3D world we will have some of the following, which I will guide you through the process of creating: A scene A renderer A camera An object or two (with materials) You can, of course, do some crazy things, and my hope is that you will go on to do that and start to experiment with 3D in your browser. 2. Just a quick note on support in the browsers. 3. Not too tricky, really! 4. All good, but what about the material for the sphere?

Viewing Models from Maya in WebGL with three.js Here is the most basic, stripped down Javascript and HTML to load and view a model exported from Maya with textures in three.js with WebGL. I use this example as a test script to check my models before loading them into other applications. Checkout this link on Stack Overflow if you want more advanced control of loading textures that were exported from a 3D package. Model or load the object you want to view in Maya. You may need to load the objExport plugin by going to Window Settings/Preferences Plug-in Manager and selecting the objExport.bundle Export the model as an Wavefront OBJ file. Run the three.js obj converter Python script on the exported file by using this syntax. python convert_obj_three.py -i chameleon.obj -o chameleon.js Use this HTML/Javascript file to load and animate your model. Change line 71 to reference your model. callbackKey = function(geometry){createScene(geometry, 0, 0, 0, 15, "chameleon.jpg")}; Change line 72 to reference your model.

WebGL 3D model viewer using three.js – Radiated Pixel var container; var camera, scene, renderer; var mouseX = 0, mouseY = 0; var windowHalfX = window.innerWidth / 2; var windowHalfY = window.innerHeight / 2; init(); animate(); /*** Initialize ***/ function init() { // This <div> will host the canvas for our scene. container = document.createElement( 'div' ); document.body.appendChild( container ); // You can adjust the cameras distance and set the FOV to something // different than 45°. camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 ); camera.position.z = 100; // These variables set the camera behaviour and sensitivity. controls = new THREE.TrackballControls( camera ); controls.rotateSpeed = 5.0; controls.zoomSpeed = 5; controls.panSpeed = 2; controls.noZoom = false; controls.noPan = false; controls.staticMoving = true; controls.dynamicDampingFactor = 0.3; // This is the scene we will add all objects to. scene = new THREE.Scene(); // You can set the color of the ambient light to any value. scene.add( ambient );

Importing a Modeled Mesh From Blender to Three.js - Jonathan Petitcolas It has been a very long time since the last Three.js rotating cube post. Better late than never, right? Here is the next part about the import and animation of a more complex mesh created in a modeling software. Yet, as we are not designer (and a fortiori, not 3D designer), we will focus on a not too complicated mesh: the marmelab logo. Modeling Marmelab Logo with Blender We are going to use Blender, a free and open-source 3D modeler. Export a Blender Mesh in JSON for Three.js Now that we got our mesh (you can download it here), let's take a look on how to export it for Three.js. Then, open the File > User preferences and go to the Addons tab. Once saved, your file should look like the following: All required data is here. Importing Mesh From Blender in Three.js Now we got our mesh into an understandable format, let's import it in Three.js. var mesh = null;function initMesh() { var loader = new THREE.JSONLoader(); loader.load('. npm install -g http-server http-server . Rotating a Mesh Woohoo!

GitHub - tishmanconstruction/3d-model-viewer: 3d model viewer How to Enable WebGL for Blocked Graphics Cards in Firefox WebGL is amazing. Take a look at X-Wing or First-Person Tetris in Firefox. What do you mean it’s not working? My laptop’s two years old but, despite having a reasonable dedicated graphics card, WebGL is disabled in Firefox. NVIDIA cards require a driver numbered 8.17.12.5721 or greaterAMD/ATI cards are 8.741.0.0 or greaterIntel cards normally require 6.14.11 on XP, 7.15.10 on Vista or 8.15.10 on 7 (although some products are completely blocked)Macs require OS version 10.6 or newer In general, blacklisting is a good thing. Unfortunately, hardware vendors stop producing drivers for legacy products (anything released before last Tuesday). And all you Chrome users can stop giggling — Google is adopting GPU blacklists in their browser shortly. Big Red Warning We’re about to bypass Firefox’s GPU blacklist. Here Be Dragons Type about:config in Firefox’s address bar and make the following changes: Now, cross your fingers, restart Firefox and try running a WebGL application.

The Beginner's Guide to three.js In this step-by-step guide, we’re going to create a 3D version of the Treehouse logo using three.js, which is a 3D graphics framework built on top of WebGL. Click and drag your mouse to orbit the camera! You can also use your mousewheel to zoom in and out. See the Demo Download the Code View on CodePen Note: You’ll need the desktop version of either Chrome, Firefox, or Safari. 3D graphics can be difficult, especially 3D in the browser. Even though three.js might look complex at first, it would actually take even more code to write the same thing in pure WebGL, mostly because we’d need to write a rendering engine. Browser Compatibility For this tutorial, you’ll need the desktop version of either Chrome, Firefox, or Safari. Also, if you’re using Safari, you need to enable WebGL first. Open the Preferences menu.Click on the Advanced tab.Click the checkbox that says Show Develop menu in menu bar.Open the Develop menu from the menu bar and select Enable WebGL. Getting Started Download three.js

How to run things locally · mrdoob/three.js Wiki Procedural content If you use just procedural geometries and don't load any textures, webpages should work straight from the file system, just double-click on HTML file in a file manager and it should appear working in the browser (accessed as Content loaded from external files If you load models or textures from external files, due to browsers' "same origin policy" security restrictions, loading from a file system will fail with a security exception. There are two ways how to solve this: Change security for local files in a browser (access page as files from a local server (access page as If you use option 1, be aware that you may open yourself to some vulnerabilities if using the same browser for a regular web surfing. Change local files security policy Safari Enable the develop menu using the preferences panel, under Advanced -> "Show develop menu in menu bar" Chrome Close all running Chrome instances first. Firefox To run:

Related: