threejs — 16 鬼屋实现

本文详细介绍了如何使用Three.js库创建一个有趣的鬼屋3D场景。通过JavaScript和HTML,结合Three.js的强大功能,实现了光影效果、模型加载和交互元素,为读者展示了一段生动的前端3D动画体验。
摘要由CSDN通过智能技术生成

 

import "./style.css";
import * as THREE from "three";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
import * as dat from "dat.gui";

/**
 * Base
 */
// Debug
const gui = new dat.GUI();

// Canvas
const canvas = document.querySelector("canvas.webgl");

// Scene
const scene = new THREE.Scene();

/**
 * Textures
 */
const textureLoader = new THREE.TextureLoader();

const doorColorTexture = textureLoader.load(
  "../static/textures/door/color.jpg"
);
const doorAlphaTexture = textureLoader.load(
  "../static/textures/door/alpha.jpg"
);
const doorAmbientOcclusionTexture = textureLoader.load(
  "../static/textures/door/ambientOcclusion.jpg"
);
const doorHeightTexture = textureLoader.load(
  "../static/textures/door/height.jpg"
);
const doorNormalTexture = textureLoader.load(
  "../static/textures/door/normal.jpg"
);
const doorMetalnessTexture = textureLoader.load(
  "../static/textures/door/metalness.jpg"
);
const doorRoughnessTexture = textureLoader.load(
  "../static/textures/door/roughness.jpg"
);

const bricksColorTexture = textureLoader.load(
  "../static/textures/bricks/color.jpg"
);
const bricksAmbientOcclusionTexture = textureLoader.load(
  "../static/textures/bricks/ambientOcclusion.jpg"
);
const bricksNormalTexture = textureLoader.load(
  "../static/textures/bricks/normal.jpg"
);
const bricksRoughnessTexture = textureLoader.load(
  "../static/textures/bricks/roughness.jpg"
);

const grassColorTexture = textureLoader.load(
  "../static/textures/grass/color.jpg"
);
const grassAmbientOcclusionTexture = textureLoader.load(
  "../static/textures/grass/ambientOcclusion.jpg"
);
const grassNormalTexture = textureLoader.load(
  "../static/textu
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值