Help us understand the problem. What is going on with this article?

blenderでモデルを作成して環境マッピングした話

More than 3 years have passed since last update.

はじめに

12/23のBlender勉強会で作成したモデルをthree.jsを使って環境マッピングしてみました。
基本的にはBlender Three.js ガラス その2(環境マップ)の2番煎じです。

作成したモデル

pet.png

ペットボトルです。(お手本見ずに適当に円柱こねくり回しました)

Three.jsで表示

使用したテクスチャhttp://opengameart.org/content/winter-skyboxes

            const scene = new THREE.Scene();
            const renderer = new THREE.WebGLRenderer();
            const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
            camera.position.z = 5;

            const urls = ['./Forest/posx.jpg', './Forest/negx.jpg', './Forest/posy.jpg', './Forest/negy.jpg', './Forest/posz.jpg', './Forest/negz.jpg'];

            scene.background = new THREE.CubeTextureLoader().load(urls);

            const control = new THREE.OrbitControls(camera);

            const container = document.createElement("div");
            document.body.appendChild(container);
            container.appendChild(renderer.domElement);

            renderer.setSize(window.innerWidth, window.innerHeight);
            renderer.setClearColor( 0xeeeeee );

            new THREE.JSONLoader().load("petbottle.json", (geom, mat) => {
                const material = new THREE.MeshBasicMaterial( {
                    color: 0xffffff,
                    envMap: scene.background ,
                    refractionRatio: 0.7,
                    reflectivity: 1,
                    opacity: 0.6, 
                    transparent: true
                } );
                const mesh = new THREE.Mesh(geom, material);
                scene.add(mesh);

                render();
            });

            function render() {
                requestAnimationFrame(render);
                control.update();
                renderer.render(scene, camera);
            }

bloggif_585ceb2e6712a.gif

かんたん!!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした