123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>three.js webgl - loaders - vrml loader</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <link type="text/css" rel="stylesheet" href="main.css">
- <style>
- body {
- color: #444;
- }
- a {
- color: #08f;
- }
- </style>
- </head>
- <body>
- <div id="info">
- <a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> -
- vrml format loader test
- <!--model from <a href="http://cs.iupui.edu/~aharris/webDesign/vrml/" target="_blank" rel="noopener">VRML 2.0 Tutorial</a>,-->
- </div>
- <script type="module">
- import * as THREE from '../build/three.module.js';
- import Stats from './jsm/libs/stats.module.js';
- import { OrbitControls } from './jsm/controls/OrbitControls.js';
- import { VRMLLoader } from './jsm/loaders/VRMLLoader.js';
- var camera, scene, renderer, stats;
- init();
- animate();
- function init() {
- camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.01, 1e10 );
- camera.position.z = 6;
- scene = new THREE.Scene();
- scene.add( camera );
- // light
- var dirLight = new THREE.DirectionalLight( 0xffffff );
- dirLight.position.set( 200, 200, 1000 ).normalize();
- camera.add( dirLight );
- camera.add( dirLight.target );
- var loader = new VRMLLoader();
- loader.load( 'models/vrml/house.wrl', function ( object ) {
- scene.add( object );
- } );
- // renderer
- renderer = new THREE.WebGLRenderer();
- renderer.setPixelRatio( window.devicePixelRatio );
- renderer.setSize( window.innerWidth, window.innerHeight );
- document.body.appendChild( renderer.domElement );
- // controls
- var controls = new OrbitControls( camera, renderer.domElement );
- //
- stats = new Stats();
- document.body.appendChild( stats.dom );
- //
- window.addEventListener( 'resize', onWindowResize, false );
- }
- function onWindowResize() {
- camera.aspect = window.innerWidth / window.innerHeight;
- camera.updateProjectionMatrix();
- renderer.setSize( window.innerWidth, window.innerHeight );
- }
- function animate() {
- requestAnimationFrame( animate );
- renderer.render( scene, camera );
- stats.update();
- }
- </script>
- </body>
- </html>
|