Importing models

Although it's possible to make nice scenes with spheres and cubes, most of the rooms you will create will involve objects created in 3D modelling programs. These can be imported with a simple statement. 

<import id="chair" src="chair.dae" rx="270deg"></import>

This presumes you have a DAE file sitting on your web server with the object you need. Here is one that I used for this example:

http://www.3dvia.com/models/9A414190A2B48698/ikea-po-ng

I needed to rename the file and include the texture for it to work.

Here is the complete code. Notice the y value on the group - this is to simulate the user standing over the chair:


<html>
<head>
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <script src="glam.min.js" ></script>
</head>
<body>
<div id="container" style="width: 100%; height: 100%; position: absolute;">
    <glam>
        <scene>
            <renderer type="cardboard"></renderer>
            <controller type="deviceOrientation"></controller>
            <group z="-3" y="-2">
                <import id="chair" src="chair.dae" rx="270deg"></import>
            </group>
        </scene>
    </glam>
</div>
</body>
</html>

No comments:

Post a Comment