-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c662266
Showing
18 changed files
with
6,941 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.parcel-cache | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": [ | ||
"@parcel/config-default" | ||
], | ||
"reporters": [ | ||
"...", | ||
"parcel-reporter-static-files-copy" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Low-Poly Cottage in WebGL | ||
|
||
A scene of a low-poly cottage rendered in WebGL using [Three.js](https://threejs.org/). | ||
|
||
**http://cottage.mikemurry.com** | ||
|
||
![Screenshot of a low-poly 3d cottage.](./docs/cottage.jpg) | ||
|
||
## Making Of | ||
|
||
The 3d model was built in Blender, adapted from the ["Low Poly Landscapes"](https://www.gamedev.tv/courses/1462117) course on [GameDev.tv](https://www.gamedev.tv). A time-lapse of the creation of the model is available on YouTube: https://youtu.be/xQi_ulWv4iA | ||
|
||
[![](./docs/youtube.jpg)](https://youtu.be/xQi_ulWv4iA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { | ||
Scene, | ||
PerspectiveCamera, | ||
WebGLRenderer, | ||
BoxGeometry, | ||
MeshBasicMaterial, | ||
Mesh, | ||
} from "three"; | ||
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js"; | ||
|
||
const scene = new Scene(); | ||
const camera = new PerspectiveCamera( | ||
75, | ||
window.innerWidth / window.innerHeight, | ||
0.1, | ||
1000 | ||
); | ||
const renderer = new WebGLRenderer(); | ||
const loader = new GLTFLoader(); | ||
|
||
renderer.setSize(window.innerWidth, window.innerHeight); | ||
document.body.appendChild(renderer.domElement); | ||
|
||
const geometry = new BoxGeometry(); | ||
const material = new MeshBasicMaterial({ color: 0x00ff00 }); | ||
const cube = new Mesh(geometry, material); | ||
|
||
scene.add(cube); | ||
|
||
camera.position.z = 5; | ||
|
||
loader.load( | ||
"cottage.gltf", | ||
function (gltf) { | ||
scene.add(gltf.scene); | ||
console.log(gltf); | ||
|
||
const objects = {}; | ||
|
||
console.log(gltf.scene.children); | ||
|
||
gltf.scene.children.forEach((child) => { | ||
if (child) { | ||
objects[child.name] = child; | ||
} | ||
}); | ||
|
||
console.log(children); | ||
}, | ||
function (xhr) { | ||
console.log((xhr.loaded / xhr.total) * 100 + "% loaded"); | ||
}, | ||
function (error) { | ||
console.error(error); | ||
} | ||
); | ||
|
||
function animate() { | ||
requestAnimationFrame(animate); | ||
cube.rotation.x += 0.01; | ||
cube.rotation.y += 0.01; | ||
renderer.render(scene, camera); | ||
} | ||
|
||
animate(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.