일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Statistics
- Deep learning
- 인공지능
- 우리들교회
- MongoDB
- WebGL
- 빅데이터
- probability
- nodeJS
- 몽고디비
- 김양재
- data science
- Machine Learning
- 빅데이타
- 김양재 목사
- No SQL
- openCV
- 데이터 과학
- Big Data
- 김양재 목사님
- Artificial Intelligence
- 딥러닝
- 빅 데이타
- 확률
- node.js
- R
- 빅 데이터
- 주일설교
- c++
- 통계
Archives
- Today
- Total
Scientific Computing & Data Science
[WebGL] Geometry Basic 본문
이번 예제는 기본적인 Geometry에 대한 것입니다. 기본적인 Geometry라 함은, Three.js가 제공하는 Geometry Primitives를 의미합니다.
Download Project
Click here to view with full screen mode
Operations
Mouse Left Button Click & Drag: Camera Rotating
Mouse Wheel: Camera Zoom In & Out
Mouse Right Button Click & Drag: Camera Panning
main.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | // MAIN // standard global variables var container, scene, camera, renderer, controls, stats; var keyboard = new THREEx.KeyboardState(); var clock = new THREE.Clock(); // custom global variables var mesh; init(); animate(); // FUNCTIONS function init() { // SCENE scene = new THREE.Scene(); // CAMERA var SCREEN_WIDTH = window.innerWidth, SCREEN_HEIGHT = window.innerHeight; var VIEW_ANGLE = 45, ASPECT = SCREEN_WIDTH / SCREEN_HEIGHT, NEAR = 0.1, FAR = 20000; camera = new THREE.PerspectiveCamera( VIEW_ANGLE, ASPECT, NEAR, FAR); scene.add(camera); camera.position.set(0,150,400); camera.lookAt(scene.position); // RENDERER if ( Detector.webgl ) renderer = new THREE.WebGLRenderer( {antialias:true} ); else renderer = new THREE.CanvasRenderer(); renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT); container = document.getElementById( 'ThreeJS' ); container.appendChild( renderer.domElement ); // EVENTS THREEx.WindowResize(renderer, camera); THREEx.FullScreen.bindKey({ charCode : 'f'.charCodeAt(0) }); // CONTROLS controls = new THREE.OrbitControls( camera, renderer.domElement ); // STATS stats = new Stats(); stats.domElement.style.position = 'absolute'; stats.domElement.style.bottom = '0px'; stats.domElement.style.zIndex = 100; //container.appendChild( stats.domElement ); // LIGHT var light = new THREE.PointLight(0xffffff); light.position.set(100,250,100); scene.add(light); // FLOOR var floorTexture = new THREE.ImageUtils.loadTexture( 'img/Wood_floor.jpg' ); floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping; floorTexture.repeat.set( 1, 1 ); var floorMaterial = new THREE.MeshBasicMaterial( { map: floorTexture, side: THREE.DoubleSide } ); var floorGeometry = new THREE.PlaneGeometry(1000, 1000, 10, 10); var floor = new THREE.Mesh(floorGeometry, floorMaterial); floor.position.y = -0.5; floor.rotation.x = Math.PI / 2; scene.add(floor); // SKYBOX var skyBoxGeometry = new THREE.CubeGeometry( 10000, 10000, 10000 ); var skyBoxMaterial = new THREE.MeshBasicMaterial( { color: 0x9999ff, side: THREE.BackSide } ); var skyBox = new THREE.Mesh( skyBoxGeometry, skyBoxMaterial ); scene.add(skyBox); //////////// // CUSTOM // //////////// // ADD A SPHERE GEOMETRY var sphereGeometry = new THREE.SphereGeometry( 20, 32, 16 ); // radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength var sphereMaterial = new THREE.MeshLambertMaterial( { color: 0x000088 } ); sphereMesh = new THREE.Mesh( sphereGeometry, sphereMaterial ); sphereMesh.position.set(0,40,0); scene.add(sphereMesh); // ADD A CUBE GEOMETRY var cubeGeometry = new THREE.CubeGeometry( 30, 32, 32 ); // width, height, depth, widthSegments, heightSegments, depthSegments var cubeMaterial = new THREE.MeshLambertMaterial( { color: 0x7dc9b6 } ); cubeMesh = new THREE.Mesh( cubeGeometry, cubeMaterial ); cubeMesh.position.set(-40,40,0); scene.add(cubeMesh); // ADD A CYLINDER GEOMETRY var cylinderGeometry = new THREE.CylinderGeometry( 15, 15, 32, 32 ); // radiusTop, radiusBottom, height, radiusSegments, heightSegments, openEnded var cylinderMaterial = new THREE.MeshLambertMaterial( { color: 0xdf18bc } ); cylinderMesh = new THREE.Mesh( cylinderGeometry, cylinderMaterial ); cylinderMesh.position.set(40,40,0); scene.add(cylinderMesh); // ADD A TORUS GEOMETRY var torusGeometry = new THREE.TorusGeometry( 13, 5, 5, 32, Math.PI * 2 ); // radius, tube, radialSegments, tubularSegments, arc var torusMaterial = new THREE.MeshLambertMaterial( { color: 0xdfdd18 } ); torusMesh = new THREE.Mesh( torusGeometry, torusMaterial ); torusMesh.position.set(80,40,0); scene.add(torusMesh); } function animate() { requestAnimationFrame( animate ); render(); update(); } function update() { if ( keyboard.pressed("z") ) { // do something } controls.update(); stats.update(); } function render() { renderer.render( scene, camera ); } | cs |
'Programming > WebGL(ThreeJS)' 카테고리의 다른 글
[WebGL] Cube Map (0) | 2015.08.06 |
---|---|
[WebGL] Material Basic (0) | 2015.08.06 |
[WebGL] Web-Cam Texture (0) | 2015.08.06 |
[WebGL] Web-Cam으로 화면 출력하기 (0) | 2015.08.06 |
[WebGL] WebGL Template (0) | 2015.08.06 |
Comments