*** chapter-10/02-bump-map.html Wed Jun 12 16:58:39 2024
--- nitta-10bezier/kadai10bezierAbbr.html Wed Jun 12 17:05:24 2024
***************
*** 44,55 ****
webGLRenderer.setSize(window.innerWidth, window.innerHeight);
webGLRenderer.shadowMapEnabled = true;
! var sphere1 = createMesh(new THREE.BoxGeometry(15, 15, 2), "stone.jpg");
sphere1.rotation.y = -0.5;
sphere1.position.x = 12;
scene.add(sphere1);
! var sphere2 = createMesh(new THREE.BoxGeometry(15, 15, 2), "stone.jpg", "stone-bump.jpg");
sphere2.rotation.y = 0.5;
sphere2.position.x = -12;
scene.add(sphere2);
--- 44,55 ----
webGLRenderer.setSize(window.innerWidth, window.innerHeight);
webGLRenderer.shadowMapEnabled = true;
! var sphere1 = createMesh(new THREE.ShapeGeometry(drawShape()), "stone.jpg");
sphere1.rotation.y = -0.5;
sphere1.position.x = 12;
scene.add(sphere1);
! var sphere2 = createMesh(new THREE.ShapeGeometry(drawShape()), "stone.jpg", "stone-bump.jpg");
sphere2.rotation.y = 0.5;
sphere2.position.x = -12;
scene.add(sphere2);
***************
*** 66,74 ****
// position and point the camera to the center of the scene
camera.position.x = 00;
! camera.position.y = 12;
! camera.position.z = 28;
! camera.lookAt(new THREE.Vector3(0, 0, 0));
var ambiLight = new THREE.AmbientLight(0x242424);
scene.add(ambiLight);
--- 66,74 ----
// position and point the camera to the center of the scene
camera.position.x = 00;
! camera.position.y = 32;
! camera.position.z = 58;
! camera.lookAt(new THREE.Vector3(0, 5, 0));
var ambiLight = new THREE.AmbientLight(0x242424);
scene.add(ambiLight);
***************
*** 94,103 ****
--- 94,107 ----
this.changeTexture = function (e) {
var texture = THREE.ImageUtils.loadTexture("../assets/textures/general/" + e + ".jpg");
+ texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
+ texture.repeat.set(0.1,0.1);
sphere2.material.map = texture;
sphere1.material.map = texture;
var bump = THREE.ImageUtils.loadTexture("../assets/textures/general/" + e + "-bump.jpg");
+ bump.wrapS = texture.wrapT = THREE.RepeatWrapping;
+ bump.repeat.set(0.1,0.1);
sphere2.material.bumpMap = bump;
};
***************
*** 116,129 ****
--- 120,148 ----
render();
+ function drawShape() {
+
+ // create a basic shape
+ var shape = new THREE.Shape();
+
+ // 自分で自由曲線で形を定義すること
+
+ // return the shape
+ return shape;
+ }
+
function createMesh(geom, imageFile, bump) {
var texture = THREE.ImageUtils.loadTexture("../assets/textures/general/" + imageFile);
+ texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
+ texture.repeat.set(0.1,0.1);
geom.computeVertexNormals();
var mat = new THREE.MeshPhongMaterial();
mat.map = texture;
if (bump) {
var bump = THREE.ImageUtils.loadTexture("../assets/textures/general/" + bump);
+ bump.wrapS = bump.wrapT = THREE.RepeatWrapping;
+ bump.repeat.set(0.1,0.1);
mat.bumpMap = bump;
mat.bumpScale = 0.2;
console.log('d');
|