feat: load 3d nds model
11
public/nintendo-ds/license.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
Model Information:
|
||||
* title: Nintendo DS
|
||||
* source: https://sketchfab.com/3d-models/nintendo-ds-934fdde060874d5c99b40cdf1dbb37f2
|
||||
* author: solal.sblt (https://sketchfab.com/Solal.Sebillotte)
|
||||
|
||||
Model License:
|
||||
* license type: CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
|
||||
* requirements: Author must be credited. Commercial use is allowed.
|
||||
|
||||
If you use this 3D model in your project be sure to copy paste this credit wherever you share it:
|
||||
This work is based on "Nintendo DS" (https://sketchfab.com/3d-models/nintendo-ds-934fdde060874d5c99b40cdf1dbb37f2) by solal.sblt (https://sketchfab.com/Solal.Sebillotte) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
|
||||
BIN
public/nintendo-ds/scene.bin
Normal file
1706
public/nintendo-ds/scene.gltf
Normal file
BIN
public/nintendo-ds/textures/base.002_baseColor.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
public/nintendo-ds/textures/base.002_metallicRoughness.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
public/nintendo-ds/textures/base.002_normal.png
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
BIN
public/nintendo-ds/textures/button_general.001_baseColor.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
public/nintendo-ds/textures/screen_down.002_baseColor.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 79 KiB |
BIN
public/nintendo-ds/textures/screen_down.002_normal.png
Normal file
|
After Width: | Height: | Size: 534 KiB |
BIN
public/nintendo-ds/textures/screen_up.002_baseColor.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
public/nintendo-ds/textures/screen_up.002_metallicRoughness.png
Normal file
|
After Width: | Height: | Size: 222 B |
BIN
public/nintendo-ds/textures/screen_up.002_normal.png
Normal file
|
After Width: | Height: | Size: 226 KiB |
BIN
public/nintendo-ds/textures/top.002_baseColor.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
public/nintendo-ds/textures/top.002_metallicRoughness.png
Normal file
|
After Width: | Height: | Size: 1000 KiB |
BIN
public/nintendo-ds/textures/top.002_normal.png
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
21
src/main.ts
@@ -1,11 +1,13 @@
|
||||
import "./style.css";
|
||||
|
||||
import * as THREE from "three";
|
||||
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
||||
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
||||
|
||||
const scene = new THREE.Scene();
|
||||
const camera = new THREE.PerspectiveCamera(75, 0, 0.001, 1000);
|
||||
const renderer = new THREE.WebGLRenderer();
|
||||
renderer.setClearColor(0xffffff);
|
||||
|
||||
const controls = new OrbitControls(camera, renderer.domElement);
|
||||
|
||||
@@ -14,15 +16,30 @@ const handleResize = () => {
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
}
|
||||
};
|
||||
window.addEventListener("resize", handleResize, false);
|
||||
handleResize();
|
||||
|
||||
// load nds model
|
||||
const loader = new GLTFLoader();
|
||||
const nds = await loader.loadAsync("/nintendo-ds/scene.gltf");
|
||||
nds.scene.scale.set(50, 50, 50);
|
||||
scene.add(nds.scene);
|
||||
|
||||
// create light
|
||||
const color = 0xffffff;
|
||||
const intensity = 3;
|
||||
const ambient = new THREE.AmbientLight(color, intensity);
|
||||
scene.add(ambient);
|
||||
|
||||
const directional = new THREE.DirectionalLight(color, intensity);
|
||||
directional.target = nds.scene;
|
||||
directional.position.set(0, 100, 0);
|
||||
scene.add(directional);
|
||||
|
||||
renderer.setAnimationLoop(() => {
|
||||
controls.update();
|
||||
|
||||
|
||||
renderer.render(scene, camera);
|
||||
});
|
||||
|
||||
|
||||