달력

52024  이전 다음

  • 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
반응형

애플코딩 보고 따라 처봄

https://www.youtube.com/watch?v=CojyGfCMvuU

<!DOCTYPE html>
<html lang="en">
<head>    
    <title>Document</title>
</head>
<body>
    
    <canvas id="canvas" width="300" height="300"></canvas>
    
    <script type="importmap">
    {
      "imports": {
        "three": "https://unpkg.com/three@0.141.0/build/three.module.js",
        "GLTFLoader" : "https://unpkg.com/three@0.141.0/examples/jsm/loaders/GLTFLoader.js",
        "OrbitControls" : "https://unpkg.com/three@0.141.0/examples/jsm/controls/OrbitControls.js"
      }
    }
  </script>

  <script type="module">
    import {GLTFLoader} from 'GLTFLoader';
    import * as THREE from 'three';
    import { OrbitControls } from 'OrbitControls';

    let scene = new THREE.Scene();
    let renderer = new THREE.WebGLRenderer({
        canvas : document.querySelector('#canvas'),
        antialias : true
    });

    renderer.outputEncoding = THREE.sRGBEncoding;

    let camera = new THREE.PerspectiveCamera(30, 1);
    camera.position.set(0,0,5);

    scene.background = new THREE.Color('white');
    //let light = new THREE.DirectionalLight(0xffff00, 10);
    //scene.add(light);
    
    let loader = new GLTFLoader();
    
    let controls = new OrbitControls( camera, renderer.domElement );
    controls.rotateSpeed = 1.0; // 마우스로 카메라를 회전시킬 속도입니다. 기본값(Float)은 1입니다.        
    controls.zoomSpeed = 1.2; // 마우스 휠로 카메라를 줌 시키는 속도 입니다. 기본값(Float)은 1입니다.        
    controls.panSpeed = 0.8; // 패닝 속도 입니다. 기본값(Float)은 1입니다.        
    //controls.minDistance = 5; // 마우스 휠로 카메라 거리 조작시 최소 값. 기본값(Float)은 0 입니다.        
    //controls.maxDistance = 100; // 마우스 휠로 카메라 거리 조작시 최대 값. 기본값(Float)은 무제한 입니다.

    loader.load('shiba/scene.gltf', function(gltf){
        scene.add(gltf.scene);
        
        function animate(){
          requestAnimationFrame(animate)
          //gltf.scene.rotation.y += 0.01;

          renderer.render(scene, camera);
          controls.update();
        }

        animate();
    });
  </script>
</body>
</html>

 

결과물 스샷

 

Posted by 유령회사
|
반응형

Posted by 유령회사
|
반응형

간단한 설정을 저장하고 지정할때 ini파일같은거도 만들기는 하는데

간단하게 설정하는 방법있다.

Settings.settings에 값을 넣어두고 설정하고 빼내기가 가능하다.

이렇게 설정을 하고

이런식으로 사용하면 된다. 

Posted by 유령회사
|